Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron job mysteriously stopped running?

Tags:

linux

crontab

I have a cron job on an Ubuntu 10.4 server that stopped running for no apparent reason. (The job ran for months and has not been changed.) I am not a *nix guru so I plead ignorance if this is a simple problem. I can't find any reason or indication why this job would have stopped. I've restarted the server without success. Here's the job:

# m h  dom mon dow   command
0 * * * * java -jar /home/mydir/myjar.jar >>/home/mydir/crontaboutput.txt

The last line in the output file shows that the program ran on 8/29/2012. Nothing after that.

Any ideas where to look?

like image 967
user1071914 Avatar asked Nov 08 '12 22:11

user1071914


2 Answers

There should be something in your system log when the job was run. The other thing you could >try is to add 2>&1 to the job to see any errors in your text file. – Lars Kotthoff yesterday

This proved to be the key piece of information - adding 2>&1 allowed me to capture an error that wasn't getting reported anywhere else. The completed command line then looked like:

java -jar /home/mydir/myjar.jar  2>&1  >>/home/mydir/crontaboutput.txt
like image 100
user1071914 Avatar answered Oct 07 '22 08:10

user1071914


Perhaps your cron daemon has stopped, or changed configuration (i.e. /etc/cron.deny). I suggest to make a shell script, and running it from crontab. I also suggest to run thru your crontab some other program (just for testing) at some other time. You can use the logger command in your shell script for syslog. Look into system log files.

like image 39
Basile Starynkevitch Avatar answered Oct 07 '22 08:10

Basile Starynkevitch