Contact
I prefer this updated version:
#!/bin/bash
check=$1 maxage=30 file='/tmp/zimbra_status'
#check if file exists if [[ -e $file ]] then
OLD=`stat -c %Z $file` NOW=`date +%s`
# if older then maxage, update file if [[ `expr $NOW - $OLD` -gt $maxage ]] then sudo -u zimbra /opt/zimbra/bin/zmcontrol status > $file fi
else
sudo -u zimbra /opt/zimbra/bin/zmcontrol status > $file
fi
status=`cat $file |grep $check|awk '{ print $2 }'`
if [[ $status != "Running" ]] then echo 0 else echo 1 fi
More information about formatting options
Click a term to initiate a search.
1. I prefer this updated
I prefer this updated version:
#!/bin/bash
check=$1
maxage=30
file='/tmp/zimbra_status'
#check if file exists
if [[ -e $file ]]
then
OLD=`stat -c %Z $file`
NOW=`date +%s`
# if older then maxage, update file
if [[ `expr $NOW - $OLD` -gt $maxage ]]
then
sudo -u zimbra /opt/zimbra/bin/zmcontrol status > $file
fi
else
sudo -u zimbra /opt/zimbra/bin/zmcontrol status > $file
fi
status=`cat $file |grep $check|awk '{ print $2 }'`
if [[ $status != "Running" ]]
then
echo 0
else
echo 1
fi