crond service
In daemon mode without the need for human intervention in the process down a series of operations and service instructions
- Check the service status
- systemctl status cron.service
- Out of service
- systemctl stop cron.service
- Start Service
- systemctl start cron.service
- Restart Service
- systemctl restart cron.service
crontab
- Instruction format: crontab [options]
- -l: List crontab currently exist
- -e: Edit crontab
- -r: Remove all tasks
Content format:
* * * * * 级别 命令(shell脚本绝对路径) 分 时 日 月 周
Examples of crontab time
每分钟(10:01,10:02 ...)
* * * * * 或 */1 * * * *
每小时
0 * * * *
每天
0 0 * * *
每周
0 0 * * 0
每月
0 0 1 * *
每年
0 0 1 1 *
每天早上6点
0 6 * * *
每2小时
0 */2 * * *
每小时10分,40分
10,40 * * * *
每天下午4,5,6点的 1,2,3,4,5min
1,2,3,4,5 16,17,18 * * *
Examples
Each additional minute to the log file one line hello world
Write test.sh
echo "hello world " >> /var/test.logs
Write crontab step
1.查看当前任务列表
crontab -l
2.进入crontab编辑界面
crontab -e
3.末尾加入
* * * * * sh test.sh的绝对路径