Skip to main content
Question

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

  • August 6, 2015
  • 3 replies
  • 16 views

donmontalvo
Forum|alt.badge.img+36

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

3 replies

dpertschi
Forum|alt.badge.img+19
  • Contributor
  • August 6, 2015

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


donmontalvo
Forum|alt.badge.img+36
  • Author
  • Hall of Fame
  • August 7, 2015

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


donmontalvo
Forum|alt.badge.img+36
  • Author
  • Hall of Fame
  • August 17, 2015

Shorter:

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