cron
Description
Each user has a cron tab, which basically is just a text file.
This file contains cron jobs for the user, that will be automatically ran and also when they will run.
Syntax
crontab -e | e is for edit and it will open the crontab file for editing |
The crontab file is split into rows and colums. Each row will represent a command or script you want to execute. Each row contains 6 columns, with the first 5 being scheduling columns, and the last column the actual command or script to be run Col 1 : minute - 0 to 59 Col 2 : hour - 0 to 23 Col 3 : day of the month Col 4 : month - 1 to 12 or JAN to DEC Col 5 : day of the week - 0 to 6 with 0 being sunday and 6 being saturday. can also use MON - SUN Col 6 : command or script to execute |
|
Run a command that outputs the text 'hello world' to a file every minute all year round We will enter a new row in our crontab file |
|
* * * * * echo "Hello World" >> ~/Desktop/hello.txt | * : means any value |
0,15,30,45 * * * * echo "Hello World" >> ~/Desktop/hello.txt | 0,15,30,45 - run command on the hour, and then 15, 30 and 45 minutes past the hour |
*/15 * * * * echo "Hello World" >> ~/Desktop/hello.txt | run command every 15 minutes |
*/15 * */3 * * echo "Hello World" >> ~/Desktop/hello.txt | run command every 15 minutes, every third day |
59 23 * JAN,DEC SUN echo "Hello World" >> ~/Desktop/hello.txt | run command once a week at 23:59 on Sundays only in December and January |
See crontab.guru for additional help |