Hi I have to run a jar file using cron so i have written a script and crontab.
it would be great help if i could know both are corrrect or not
PATH=/usr/java/j2sdk1.4.2_12/jre18.104.22.168/bin java -jar /usr/local/lib/myjar
and crontab goes like this
1 * * * * /usr/local/lib/cron.sh
is this correct.no idea about linux so thats y basic question.
This topic has been locked.
2 replies Latest Post - 2006-10-05T17:17:28Z by SystemAdmin
Pinned topic cron job
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2006-10-05T17:17:28Z at 2006-10-05T17:17:28Z by SystemAdmin
ishields 2000001P5B988 PostsACCEPTED ANSWER
Re: cron job2006-10-05T17:13:17Z in response to SystemAdminIn general, this looks OK. Remember that you may not have stdin, stdout, or stderr defined when your process runs, so the output of your echo command, along with any ourput from the Java file will probably be lost. Use
[b]man 5 crontab[/b]
for a good introduction to the crontab format and
[b]man 1 crontab[/b]
to see how to use the crontab command to set up your crontab entry. You don't mention whether you want to set up the crontab entry as root or another user, but be aware of /etc/cron.allow and /etc/cron.deny which may affect your ability to set up the crontab entry.
If you want to test your command in user space, try creating a wrapper script that will unset all but the minimal set of environment variables used by cron, close stdin, stdout and stderr, and then call your script. See Chapter 19. I/O Redirection in the Advanced Bash Scripting Guide at the Linux Documentaiton Project for more info on closing file descriptors. You might also find Section 4.4.4. Cron and crontab of Introduction to Linux useful too.