Sunday 15 July 2012

java - schedule a job in unix by crontab -



java - schedule a job in unix by crontab -

i have created simple java programme printing "hello world". code follows

public class hello { public static void main(string[] args) { system.out.println("hello world!"); } }

class has been compiled , in same directory. in same directory have created shell file named temp.sh contains command

java hello

now if execute shell file java programme beingness executed successfully. have written cronjob execute every minute

* * * * * /home/ashutosh/documents/javapractice/temp.sh >> /var/log/myjob.log 2>&1

now in logs showing

could not load main class java

i don't know problem. have tried giving absolute path of java file nil helped. help me.

thanks

your problem working directory of cronjob not directory class resides. add together cd the_right_directory script or alter classpath of java java -cp some_directory hello

java shell unix ubuntu cron

No comments:

Post a Comment