Dave
Dave

Reputation: 8907

How to test a cron job?

I'm using Ubuntu Linux 10.0.4. I want to run a script every 6 hours, every day. When I issue sudo crontab -e, I see:

# m h  dom mon dow   command
* 00,06,12,18 * * * /opt/scripts/selenium/run_nis_inf_tests.sh

However, I'm not seeing the expected outcome from my script, and I'm not even sure if its running. Is there a way to test, short of waiting until the specified time, that the script is running properly. Or, how can I view the errors the script is generating? - Dave

Upvotes: 4

Views: 8055

Answers (2)

Alpha01
Alpha01

Reputation: 820

You can update the MAILTO variable to your email address, and cron should email you any STDOUT and STDERR output. Also check your syslog file /var/log/messages to see if the script is being executed by cron.

-Tony

Upvotes: 5

mecano
mecano

Reputation: 59

Cron should mail it results so it looks like you have a problem. Here, it seems you are missing a user to run the script as :

00,06,12,18 * * * user_name /opt/scripts/selenium/run_nis_inf_tests.sh

replace user_name by the name of the user the script needs to be run by, verify permissions of "run_nis_inf_tests.sh" and you should be ok.

Upvotes: 1

Related Questions