Verify that a cron job has completed

Solution 1:

grep scriptname /var/log/syslog

Solution 2:

/var/log/cron

you can check to if its currently running with:

ps aux

Solution 3:

To make sure a script completed successfully one should really use a temp file. Create it when the job starts and delete it when it finished. This also catches crashes and avoids running the same job again in case of errors.

#!/bin/bash

# check if there is already a temp file with suffix .myscript in /tmp,
# if file exists return with status of 666
[ -f /tmp/*.bla ] && exit 666

# create a temp file with suffix .myscript
TEMP_FILE=`mktemp --suffix .myscript`
touch $TEMP_FILE

#
# script stuff
#

# we are done, clean-up after ourselves
rm $TEMP_FILE

Solution 4:

You can also have results emailed to you.

30 3 * * * find /home/*/Maildir/.Spam/{new,cur}/ -type f -mtime +6 -delete| \
           mail -e -s "task #1 report" [email protected]