I have created some application, which is reading from System.in using the following method:
Scanner input = new Scanner(System.in);
while (input.hasNextLine()) {
String line = input.nextLine();
}
Input data is being passed with linux command:
cat -A /home/someuser/somefile.txt | java -classpath "$CLASSPATH" com.test.Main
The crontab entry looks like:
MAILTO=someuser
CLASSPATH="/home/someuser/test.jar:/usr/share/java/jdom.jar:/usr/share/java/mysql-connector-java.jar"
0,10,20,30,40,50 * * * * cat -A /home/someuser/somefile.txt | java -classpath "$CLASSPATH" com.test.Main >/home/someuser/output.txt
The permissions for the files shows the following:
-rw-r--r-- 1 someuser serhiy 8385601 2011-02-07 10:57 /home/someuser/somefile.txt
Everything is working fine on my machine(Ubuntu 9), but after installation on another machine Ubuntu 8, I figured out that program starts but seems not to be reading anything. I have triple checked all configurations and all permissions and the result still the same. When I run command manually everything is working, when it’s ran by crontab it seems not reading input. Anyone experienced this issues before?
Thanks for any help
Serhiy.
Are you defining the variables in crontab ? That does not seem right.
1) Move the command to a shell script and invoke the shell command from cron, eg
2) Contents of some_script.sh ; make sure the execute bit is set