weisia
Posts: 8
Joined: Tue Sep 08, 2015 7:11 am

SOLVED cronjob suddenly stopped working

Sun Jun 24, 2018 7:40 pm

Hi,

I have a raspberry connected to a camera and am using it to make a timelapse video with cronjob. I got it working and then tweaked some other things in crontab and now I can't get any output from the timelapse script. I am running crontab from sudo as it is the easy road to prevent permissions problems with the camera and as I am the only user. Reloading and restarting cron does not help. What am I doing wrong?
Here is my " sudo crontab -e" entry:

Code: Select all

	 * 19,20,21,22,23,24 * * * /home/pi/camera.sh  >> /home/pi/logs/timelapse.txt 2>&1
There is no log file, but when looking at the syslog it suggest cron is not running properly (the entries are from the previous timelapse with a different log file, but with the same script):

Code: Select all

Jun 18 04:34:01 picamera CRON[708]: (root) CMD (/home/pi/camera.sh >> /home/pi/ochtendlog.log 2>&1)
Jun 18 04:35:01 picamera CRON[728]: (root) CMD (/home/pi/camera.sh >> /home/pi/ochtendlog.log 2>&1)
Jun 18 04:36:02 picamera CRON[747]: (root) CMD (/home/pi/camera.sh >> /home/pi/ochtendlog.log 2>&1)
Jun 18 04:37:01 picamera CRON[766]: (root) CMD (/home/pi/camera.sh >> /home/pi/ochtendlog.log 2>&1)
Jun 18 04:38:01 picamera CRON[786]: (root) CMD (/home/pi/camera.sh >> /home/pi/ochtendlog.log 2>&1)
but cron is active

Code: Select all

● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-06-24 21:24:58 CEST; 11min ago
     Docs: man:cron(8)
 Main PID: 1440 (cron)
   CGroup: /system.slice/cron.service
           └─1440 /usr/sbin/cron -f

Jun 24 21:24:58 picamera systemd[1]: Started Regular background program processing daemon.
Jun 24 21:24:58 picamera cron[1440]: (CRON) INFO (pidfile fd = 3)
Jun 24 21:24:58 picamera cron[1440]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Last edited by weisia on Mon Jun 25, 2018 4:34 pm, edited 1 time in total.

pcmanbob
Posts: 4465
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: cronjob suddenly stopped working

Mon Jun 25, 2018 9:38 am

So looking at your cron line - * 19,20,21,22,23,24 * * * - it looks like you are trying to run the cron job every minute for the hours from 7pm to midnight.

but cron does not have a 24 in the hours field midnight is "0"

so your cron line should look like this - * 0,19-23 * * *
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

weisia
Posts: 8
Joined: Tue Sep 08, 2015 7:11 am

Re: cronjob suddenly stopped working

Mon Jun 25, 2018 4:35 pm

pcmanbob wrote:
Mon Jun 25, 2018 9:38 am
So looking at your cron line - * 19,20,21,22,23,24 * * * - it looks like you are trying to run the cron job every minute for the hours from 7pm to midnight.

but cron does not have a 24 in the hours field midnight is "0"

so your cron line should look like this - * 0,19-23 * * *
Thank you for pointing this out, this is the solution. Everything works now as intended.

Return to “Troubleshooting”