Cron job doesn't execute

Hi,

there is a jar file I have to execute everyday at 10:00 AM. I added the below options with crontab -e but it fails to execute. I appreciate if someone could help. Thanks in advance…

0 10 * * * java --add-opens java.base/java.lang=ALL-UNNAMED -jar /home/user/folder/folder/Reminder.jar

0 10 * * * root (cd /home/user/folder/folder/; java --add-opens java.base/java.lang=ALL-UNNAMED -jar Reminder.jar)

Hi,

did you tried to put your command into a script and have this executed from there?

Thanks for the reply mate. I didnt try yet. As described here:
https://unix.stackexchange.com/questions/98914/how-to-use-crontab-for-a-java-file-in-linux
???

Crontab -e will edit the cron for the user who is running the command, for example dietpi or root.
Better use the full path to the java command, otherwise it might fail for that.
Also the second command is supposed to run as root? Then you need to add it in root’s crontab.

One of those two just got executed (don’t know which one) at a completely wrong time… Does cron use a different time then the system time ?

Cron job uses the server’s define timezone if I’m not mistaken. To find the timezone

readlink -f /etc/localtime

Strange… According to output from this: readlink -f /etc/localtime
The time zone is correct…

you could check what happen on cron and what time thinks got executed

journalctl -u cron.service

Very strange… Journal said it executed in the right time… But it didn’t do anything. I tried rebooting and it suddenly started working. So everytime I add a cronjob it doesn’t take effect until I reboot but strangely before reboot, journal says the code was executed…

Probably it’s enough to restart cron.service to get it activated. But strange that this would be needed. :thinking:

Thanks for everybodys help!