File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes How to use Cron job with Java program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "How to use Cron job with Java program?" Watch "How to use Cron job with Java program?" New topic

How to use Cron job with Java program?

Steven Ho

Joined: Jan 16, 2003
Posts: 15
I am new to the Cron Job, I am trying to schedule a Java program that print current Date on System.out every 5 minutes. I put inside the command line
is "java printBeep"
But the output I get from email is

Please tell me where I went wrong, btw the interface only permits 1 line of command to input, and I can't seem to put more lines of command lines.
Please help if can, thank you all.
Have a nice day!
[ September 17, 2003: Message edited by: Steven Ho ]
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
use the complete path to the java file e.g. /usr/bin/java. I think
the cron job doesnt uses PATH variables, so you have to define the
absolute path
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
Or you can put whatever commands you like in a script file, and execute that from your "cron".

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11776

By the way, there is no System.out from within the cron job, as there is no terminal associated with the cron job.
Depending on how your cron environment is set up, you may get an email sent to you with the output that would have appeared on the screen if there had been a screen.

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
I agree. Here's the link:
subject: How to use Cron job with Java program?
jQuery in Action, 3rd edition