I have this /etc/cron.d/reboot file:
PROJECT_ROOT=/usr/local/share/applications/ana
NODE_PATH=/usr/bin/node
REBOOT_SCRIPT=/usr/sbin/reboot
SCRIPT=scripts/server-reload-messages.js
0 5 * * * root cd $PROJECT_ROOT && $NODE_PATH $SCRIPT create
1 5 * * * root $REBOOT_SCRIPT
I need the script to work once a day at 5am, but it works at 5 and 17.
Edit by comments
@roaima, thanks for the advice to look at the cron logs. Now I see that in fact it only works once a day, but then I need to rename the task. The thing is, while i using the application, I got a message that the server will now restart, I checked the date, it was 05:00 PM, I had no doubt that something was going wrong.
May 15 05:00:01 mail CROND[23278]: (root) CMD (cd $PROJECT_ROOT && $NODE_PATH $SCRIPT create )
May 16 05:00:01 mail CROND[52008]: (root) CMD (cd $PROJECT_ROOT && $NODE_PATH $SCRIPT create )
May 17 05:00:01 mail CROND[5363]: (root) CMD (cd $PROJECT_ROOT && $NODE_PATH $SCRIPT create )
May 18 05:00:01 mail CROND[19420]: (root) CMD (cd $PROJECT_ROOT && $NODE_PATH $SCRIPT create )
Here's what I managed to find out, the date format in the system is strange, it looks like this at 19:20:
date
Thu May 18 07:20:02 EDT 2023