-
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配置定時任務
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.