I am new this site as well as new to shell scripting and this is my first form. Please help me with the following shell script.
I am executing a shell script to run every 15 min (scheduled in cronjob) and it gives an output in an output file which is e-mailed.
CONCCOUNT=`cat $OUT_DIR/EBS_Locked_Accounts.out|grep INVALID |wc -l`
echo $CONCCOUNT
if [ $CONCCOUNT != 0 ]
then
outputFile="$OUT_DIR/EBS_Locked_Accounts.out"
(
echo "From: [email protected]"
echo "To: $MAILLIST"
echo "MIME-Version: 1.0"
echo "Subject: Locked Accounts in EBS"
echo "Content-Type: text/html"
cat $outputFile
) | sendmail -t
My requirement is:
I don't want the script to send output every 15 min (cannot change the cronjob schedule) instead it should send the actual output every one hour unless there is a change in the count.
It you can't change the cronjob schedule, you can create a file that counts to 4 and then sends it and resets the count, since 15 minutes*4 = 1 hour. Like this:
echo "1" > croncount.txt