一次性任務:at命令
at使用必備
1th:
1)type at
2)rpm -qf path
3)yum install 包名
4)rpm -ql at (有atd.service發現它也是個服務,即要使用at必須要開啟這個服務)
2th:
1)systemctl status atd (active running)
2)systemctl start atd
3th:ntp
同步時間(確保準就必須與服務器時間一致,,工作中時間非常重要,先配置)
1)ntpdate 172.20.0.1 ntpdate 172.20.0.1
2)vim /etc/chrony.conf /etc/ntp.conf(centos6)
server 172.20.0.1 iburst server 172.20.0.1 iburst
3)#systemctl enable chronyd(開機啟動) chkconfig ntp on
#systemctl status chronyd service ntpd status
#systemctl start chronyd service ntpd start
應用:
at -l
at -c num
ls -l /var/spool/at/
cat /var/spool/at/
at now + 2 mintues II 03pm + 3 days
at -d num
at -f somefile executetime
at now executetime < somefile(重定向標準輸出/錯誤的應用:它不會輸出到終端而是已郵件發式發給了客戶,這樣易造成大量垃圾郵件,因此最好建議重定向到null里)
at -m
文件:
/etc/at.deny /etc/at.allow (權限黑白名單)
用腳本來創建計劃任務:
eg:
vim
#!/bin/bash
at 18:10 << EOF
rm /data/* -rf
halt
EOF
周期性計劃任務:cron命令
cron使用準備
1th:
1)type crond II which crond
2)rpm -qf path
3)rpm – ql cronie (有crond.service,即使用cron工具前必須要啟動這個服務)
2th:
systemctl status crond (active 是否running)
本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/97667