cron 每两周执行
We may want to run some jobs for every two weeks/months/days… under some situation such as backing up for every other week. In addition, we may add more complex rules for running jobs, e.g. run a command when the load of the server is higher than a certain level. With the help of the shell programming language we can easily achieve this goal.
在某些情况下,例如每隔一周备份一次,我们可能希望每两周/月/天运行一些工作。 此外,我们可能会为运行作业添加更复杂的规则,例如,当服务器的负载高于特定水平时运行命令。 借助Shell 编程语言,我们可以轻松实现此目标。
crontab的基础 (Basics of the crontab)
Crontab file controls how and what to run by cron. The crontab line has a format as follows:
Crontab文件控制cron的运行方式和运行方式。 crontab行的格式如下:
.---------------- minute (0-59)
| .------------- hour (0-23)
| | .---------- day of month (1-31)
| | | .------- month (1-12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0-6) (Sunday=0 or 7) OR sun,mon,tue ...
| | | | |
* * * * * command to be executed
To add a cron job for your current user, run
要为当前用户添加cron作业,请运行
$ crontab -e