I'm trying to get crontab to automatically schedule an update via "sudo apt-get update". I have also written a script that if I run it through Terminal (/home/pi/bin/update), it runs the update script but if I schedule crontab to run the update script, nothing. I also added the command "0 05 * * * sudo apt-get update" (run update at 05:00 every morning) into crontab and nothing either. If the update is running I don't see the update running in Terminal or even know if the command has run. What could I be missing?
1 Answer
Check the log file to see if your cron command was executed:
grep CRON /var/log/syslog
Direct the output to a file to see the result of the command:
(test every minute)
*/1 * * * * sudo apt-get update > /home/pi/log.txt
(05:00 every day)
0 5 * * * sudo apt-get update > /home/pi/log.txt
pi
when runningsudo
? Why not runapt-get update
directly as root?