Schedule Cron Job Every Day at Specific Time
Cron is a scheduling service in Unix-like operating systems. It is used to schedule execution of commands.
It allows you to run commands and scripts.
The Cron service daemon runs in the background and checks for tasks.
You can, for an example, create script that updates system and runs automatically so you don’t need to worry about latest version of your system.
Starting Cronjob
Type the following command to start Cronjob:
crontab -e
If you didn’t change anything before, you will only see comment about tasks and an example hot to use it.
Let’s see how it should look like:
* * * * * /path/to/script
Now, let’s break this to pieces, each of the * meaning is bellow:
<minute> <hour> <day of month> <month> <day of week> /path/to/script
This is how you can define cron jobs:
- minute => 0 – 59
- hour => 0 – 23
- day of month => 1 – 31
- month => 1 – 12
- day of week => 0 – 6
Setting up Cronjob
Now when we know what each asterisk (*) means, we can now set our command.
For an example, if we want to run script or a command on every minute, our line in crontab will look like this:
* * * * * /path/to/script
Or
* * * * * /path/to/command
But if you want to run specific script at specific time, let’s say 12:30 PM, your line in cron tab will look like this:
30 12 * * * /path/to/script
After you entered this line, save and close file.
Your system is now ready to run your commands at time you entered in the crontab.
You can try it by running some application or something else to see if it’s working.