Google

Tuesday, September 23, 2008

cron jobs in linux

Linux provides users to schedule their jobs perioducally using crontab[0]. 
It is a realy easy task to add an entry to schedule the user task. You can list the current cron jobs using 
$crontab -l
and, you can edit it by 
$crontab -e
Use the reference for parameter settings.

One problem with this is, crontab doesn't return us the error message if it can't run the task. So it is really hard to find the problem. I had a similar problem where I had a wrong entry for the JAVA_PATH in the script. But when I run the script from the command prompt it works fine since the console knows the JAVA_PATH on its own.

Here is a very simple shell script that can be used to run a java program.

#!/bin/sh

PATH=your_java_home:${PATH}
cd point_to_the_java_directory

java class_name


And here is the simple crontab entry to run the script for every minit

* * * * * sh path_to_script/script_name



No comments: