How To Set A Cron Job
Sometimes you need your Raspberry Pi (or other computer) to run a repetitive task. Maybe you want it to take a picture every five minutes, or recite a protection spell every Friday the 13th. To do this, we can use a cron job, or a scheduled task. To add a cron job, type
You must use this order, and you may not have any missing fields. The acceptable values for each field is as follows:
You may also use *, a wildcard character for any given category. This indicates every possible value for the field. So, if you wanted to run a command every day at 1:20pm, your time portion would look like this:
Note that we’re using “13” instead of “1” for the hour slot, because we’re using a 24-hour clock. If you wanted to run something every five minutes, you would simply do:
Using the slash, we can divide the wildcard symbol by any number, causing the job to run whenever it’s evenly divisible. And if you’d like to run a script every Friday the 13th at 11:11am and 11:11pm (usually lucky times, even on a very unlucky day), you’d simply write:
Note the hour field–we can select a set of specific times by separating different values with a comma (with no spaces)! |