
Setting Up A Cron Job On The Raspberry Pi
Cron jobs are an easy way to schedule a script or program to run at specific dates and times in regular recurring cycles. These can be used for server maintenance tasks and scheduled backups, right out to real world applications for things like turning on or off lights and other automation. In this tutorial we will go through the steps of setting up a cron job on a Raspberry Pi along with some of the basic configuration options.
There are a lot of different operating systems out there for the Raspberry Pi, so we are going to focus on the most popular: Raspbian. We are using the version dated: 2019-7-10 (Pi 4 Compatible) available from the Raspberry Pi Foundations’ Download Page. You don’t need to use the Raspberry Pi 4, any Raspberry Pi will do. However, deviating from the recommended operating system version may result in different / additional steps so if you are very new to this, we recommend following the tutorial exactly.
If you have any questions, or need further clarification please post in the comments section below; this way future users of this tutorial can see the questions and answers!
Hi when I put the following command into my Raspberry Pi terminal:
/usr/bin/scrot /home/pi/Pictures/pic.png
it works.
However, when I put the following line into crontab:
* * * * * /usr/bin/scrot /home/pi/Pictures/pic.png
it doesn’t work.
Can you help please?
Many thanks
might be a permission or maybe length of the command?
I would like to know this as well. I think you need to specify the exact path for the cron to find the python or something of this sort. I also want to know how to do this
Hi your above instructions are great, I have been trying to set crontab in the same manor for days now by putting the following line “@reboot Sudo Python3 /home/pi/Desktop/gpio.py &” this file is a python script, sat on the desktop that sets the GPIO BOARD pins 11 and 16 to output hi, running it in python on a pi 3b+ works perfectly to light 2 no LED’s. I cannot get crontab to work, it appears to save the edited file and confirms saving in the terminal once nano quits but when I reboot nothing happens and after reboot running crontab -e again and the edited line has been removed.
can someone please help
I have a cron script to startup a program in raspberry pi when rpi powers up.Can i add a script to shutdown the program before rpi shutsdown on the same script file or do i need to create another cron script ???
Thank you in advance for any answers.
Go easy with the replies as i am a novice .