G
G
Geeskel2017-05-09 17:30:46
Command line
Geeskel, 2017-05-09 17:30:46

Why is the script not being executed in crontab -e?

Need help from a non-professional.
So, there is a homemade WiFi camera for Raspberry PI (Raspbian). Installed MJPG-Streamer, you need to save pictures from the camera every 5 minutes. I'm trying to make it run a shell script through crontab -e, where I ran into difficulties
. The bottom line is that the script is not executed from under cron, despite the fact that it works correctly by itself (presented below)
Crontab -e :

# m h  dom mon dow   command
*/5 *   *   *   *    sh /home/pi/mjpg-streamer/make_photo.sh 2>/var/log/make_photo

The script itself (downloads the screen from the camera with the date and time in the file name) :
#!/bin/bash
D=`date +\%d.\%m.\%Y-\%H.\%M.\%S`
/usr/bin/wget http://192.168.0.93:8081/?action=snapshot -O /media/motion/pic_$D.jpg

Execution [email protected]:~ $ sudo service cron statusdoes not output any errors:
● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled)
   Active: active (running) since Вт 2017-05-09 15:02:34 MSK; 2h 18min ago
     Docs: man:cron(8)
 Main PID: 464 (cron)
   CGroup: /system.slice/cron.service
           └─464 /usr/sbin/cron -f

май 09 17:15:01 camera CRON[2661]: (pi) CMD (sh /home/pi/mjpg-streamer/make_photo.sh 2>/var/log/make_photo)
май 09 17:15:01 camera CRON[2657]: (CRON) info (No MTA installed, discarding output)
май 09 17:15:01 camera CRON[2657]: pam_unix(cron:session): session closed for user pi
май 09 17:17:01 camera CRON[2680]: pam_unix(cron:session): session opened for user root by (uid=0)
май 09 17:17:01 camera CRON[2684]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
май 09 17:17:02 camera CRON[2680]: pam_unix(cron:session): session closed for user root
май 09 17:20:01 camera CRON[2712]: pam_unix(cron:session): session opened for user pi by (uid=0)
май 09 17:20:01 camera CRON[2716]: (pi) CMD (sh /home/pi/mjpg-streamer/make_photo.sh 2>/var/log/make_photo)
май 09 17:20:01 camera CRON[2712]: (CRON) info (No MTA installed, discarding output)
май 09 17:20:01 camera CRON[2712]: pam_unix(cron:session): session closed for user pi

Tell me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Geeskel, 2017-05-15
@Geeskel

All earned! As I thought, "the fool himself" turned out to be.
The error was in the entry of the command itself in crontab, it was necessary to specify/bin/sh
Thank you for your help

B
belunix, 2017-05-09
@belunix

tail -f /var/log/syslog
shows what?
Is your cronjob running every 5 minutes?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question