Sara
Sara

Reputation: 2436

crontab job does not work

I have a script

5 05 * * * /bin/bash -l -c 'nohup sh test.sh &'>/dev/null 2>&1 It runs prefect in bash but when I put it in crontab it does not work. As it is running on remote server I thought maybe the time zone is the problem. I ran date on the server and the output is Fri Jan 10 05:10:02 UTC 2014. Why it does not work?

Upvotes: 0

Views: 113

Answers (2)

kuldeep.kamboj
kuldeep.kamboj

Reputation: 2606

As suggest by @user1332577 Full path of test.sh is needed. Also removind /dev/null part will dump errors.

Also First check cron logs, They may be at /var/log/cron OR /var/log/syslog depends on settings. If their are no entry of this particular cron on specified time. Then obviously cron is not enabled. It also help you check timestamp when it executed.

Upvotes: 1

user1332577
user1332577

Reputation: 362

You may want to specify the full path to everything. Crons have a hard time finding things if they are not defined explicitly. Also if you have paths in test.sh you may want to specify them as well.

Additionally, if you are having trouble but aren't sure why it's not working if you put MAILTO = 'your email address' at the top and get rid of the output piped to >/dev/null it may help you find out what the error is.

Upvotes: 2

Related Questions