Extension Attribute based on a file being modified more/less than N minutes/days ago

donmontalvo
Esteemed Contributor III

Sorry, its late and I'm hungry...

#!/bin/sh
#
# If Pizza is less than 30 minutes old, return "YumYum".
# If Pizza is more than 30 minutes old, return "EwwYuk".
# Can use -mmin for minutes, or -mday for days.

Pizza=`find /path/to/pizza -mmin -30 -print`
YumYum="/path/to/pizza"
EwwYuk=""

if [ "$Pizza" == "$YumYum" ];
then
    echo "<result>YumYum</result>"
else
    echo "<result>EwwYuk</result>"
fi

<burp>

HTH,
Don

--
https://donmontalvo.com
3 REPLIES 3

dpertschi
Valued Contributor

@donmontalvo are you having side effects from wild fire smoke inhalation?

donmontalvo
Esteemed Contributor III

Haha...I had to sanitize the script, so pizza was the first thing that came to mind. :)

--
https://donmontalvo.com

donmontalvo
Esteemed Contributor III

Shorter:

#!/bin/sh
if [ `find /path/to/pizza -mmin -30 -print` ]; then
echo "<result>YumYum</result>"
else
echo "<result>EwwYuk</result>"
fi
--
https://donmontalvo.com