Processes (≒ functions) that can be used on unix OS (CentOS, Ubuntu, etc.). It is mainly used to run a program that you want to run regularly at a fixed time.
$ crontab -e
The vi editor will start up, so write according to the following rules
Minute hour day Monday day of the week username command
* * * * * root some_command
Target of designation | Specified range |
---|---|
Minutes | 0〜59 |
Time | 0〜23 |
Day | 1〜31 |
Moon | 1-12 or jan-dec |
Day of the week | 0-7 or sun-sat |
Description example
#Every minute
* * * * * root touch /home/ubuntu/test.txt
# 1:00〜1:Run up to 59 in 1 minute increments
* 1 * * * root touch /home/ubuntu/test.txt
#1 daily:Run to 00
0 1 * * * root touch /home/ubuntu/test.txt
#12th of every month~20th 00:Run to 00
0 0 12-20 * * root touch /home/ubuntu/test.txt
#Every Monday-Friday 00:Run to 00
0 0 * * 1-5 root touch /home/ubuntu/test.txt
#Show the configured cron
$ crontab -l
#Remove all cron,-Be careful not to mistake it for the e option
$ crontab -r
-How to use cron for beginners --Qiita -How to use Cron and where it got stuck-- Qiita -Summary of crontab commands [Linux command collection]
Recommended Posts