I wrote a .jar file that is supposed to be run once a day that interacts with Google App Engine. When I run it from the computer, it runs just fine and creates a logfile that details some statistics. I transferred it over to the Raspberry Pi and it runs via crontab.
The first time I ran it, I got a permission denied in syslog. I read that using 'sudo crontab -e' would fix that. Now I no longer get the error but my logfile doesn't appear.
Here is the portion of the code that is to create the logfile:
PrintWriter writer = new PrintWriter("log" + format.format(date) + ".txt"); writer.println("Total Themes: " + numThemes + "\r\n"); writer.println("Active Themes: " + numActiveThemes + "\r\n"); writer.println("Inactive Themes: " + numInactiveThemes + "\r\n"); writer.println("Total Sales: " + numSales + "\r\n"); writer.println("Total Price Changes: " + numPriceChanges + "\r\n"); writer.println("Total Time: " + seconds + " seconds" + "\r\n"); writer.close();
0 2 * * * java -jar /mnt/data/scripts/test.jar
What am I missing about the switch from Windows that is preventing the creation of the logfile?
Edit: I can run the .jar file manually (using sudo) and the logfile is created. Not working w/cron though.
Edit2: /etc/log/syslog has:
Feb 8 21:46:01 raspberrypi /USR/SBIN/CRON: (root) CMD (java -jar /mnt/data/scripts/updater_pricing.jar
Edit 3: Changed permissions of the folder and jar to 777 (as a test). Now I can run the file w/o 'sudo' (expected). Tried running a regular cron task using the same cron expression as above. Now syslog has:
Feb 9 07:55:01 raspberrypi /USR/SBIN/CRON: (pi) CMD (/usr/bin/java -jar /mnt/data/scripts/test.jar)
It also has: Feb 9 07:55:59 raspberrypi /USR/SBIN/CRON: (CRON) info (No MTA installed, discarding output)
Perhaps I can add something that will output the error message?