I have a server running AIDE, and a cron job that runs executes a bash script and sends an email alert out. It is still a WIP, but I can't get the script to run properly. When the script is executed, my output file defined here /sbin/aide --check > /tmp/$AIDEOUT
is still an empty file. I even tried a simple /bin/echo "hello world" > /tmp/$AIDEOUT
and it also doesn't seem to work. The /tmp/$AIDEOUT
file remains empty.
However, if I run this script manually without using Cron, it runs fine.
Here is my bash script
#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MYDATE=`date +%Y-%m-%d`
AIDEOUT="AIDE-${MYDATE}.txt"
MAIL_TO=
ALLMATCH='All files match AIDE database. Looks okay!'
MAIL_FROM=
/bin/touch /tmp/$AIDEOUT
/bin/chmod 755 /tmp/$AIDEOUT
#/bin/echo "Aide check `date`" > /tmp/$AIDEOUT
/sbin/aide --check > /tmp/$AIDEOUT
if ! grep -q "$ALLMATCH" /tmp/$AIDEOUT; then
/usr/bin/mailx -s "Daily AIDE report for $(hostname)-${ENVIRONMENT_NAME} ${AWS_REGION}" -r $MAILFROM $MAILTO < /tmp/$AIDEOUT
fi
#/bin/rm /tmp/$AIDEOUT
/sbin/aide --update
/usr/bin/mv /var/lib/aide/aide.db.gz /var/lib/aide/db_backup/aide.db.gz-$(date +"%m-%d-%y")
/usr/bin/mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
my cronjob is defined in /etc/cron.d/aide*/5 * * * * root /usr/local/etc/cron_aide2.sh
Thanks!
No comments:
Post a Comment