-
centos7自带定时任务crontab
没有的话安装
yum install crontabs
开机启动
systemctl enable crond
启动服务
systemctl start crond
重启
systemctl restart crond
查看状态
systemctl status crond -
设置定时任务
vim /etc/crontab
可以看到定时任务说明
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details see man 4 crontabs # Example of job definition: # .---------------- 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,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed
说明:
minute 每小时的第几分钟执行 0-59
hour 每日的第几个小时执行 0-23
day 每月的第几天执行 1-31
month 每年的第几月执行 1-12
day 每周的第几天执行 0-6*/1 * * * * root /home/test.sh 一分钟执行一次,执行脚本
* 2 * * * * root /home/test.sh 每天凌晨2点1分,执行脚本
0 2 * * * * root /home/test.sh 每天凌晨2点整,执行脚本 -
加载任务,生效
crontab /etc/crontab
-
查看定时任务
crontab -l
centos7配置定时任务
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.