I wasn't talking about a self generated log but messages in /var/log.
Using this cron entry:
Code:
*/1 * * * * /root/blaat.sh >> /tmp/backup.log
If I do the following the cron job fails:
Code:
#!/bin/bash
service mysql stop
echo "sleeping 2 seconds"
service mysql start
This can be seen in /var/log/syslog:
Code:
<time stamp> plains /USR/SBIN/CRON[16149]: (root) CMD (/root/blaat.sh >> /tmp/backup.log )
<time stamp> plains /USR/SBIN/CRON[16147]: (CRON) error (grandchild #16149 failed with exit status 127)
And this is mailed to me:
Code:
Subject: Cron <root@plains> /root/blaat.sh >> /tmp/backup.log (failed)
Date: <time stamp>
/root/blaat.sh: line 3: service: command not found
/root/blaat.sh: line 5: service: command not found
All works as expected when using this:
Code:
#!/bin/bash
/usr/sbin/service mysql stop
echo "sleeping 2 seconds"
/usr/sbin/service mysql start