IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2006-10-05T17:17:28Z by SystemAdmin
2364 Posts

Pinned topic cron job

‏2006-10-05T16:38:19Z |
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/jre1.4.2.12/bin java -jar /usr/local/lib/myjar
export PATH
echo $PATH

and crontab goes like this

1 * * * * /usr/local/lib/

is this idea about linux so thats y basic question.
Updated on 2006-10-05T17:17:28Z at 2006-10-05T17:17:28Z by SystemAdmin
  • ishields
    988 Posts

    Re: cron job

    ‏2006-10-05T17:13:17Z  in response to SystemAdmin
    In 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.

    Ian Shields.