Timing Scheduled Tasks
The main document presents:
[Nginx the root @ ~] # LL / etc / * the cron -d drwxr-XR-X. the root 21 is the root. 7 2 20:28 dated the /etc/cron.d. 11 drwxr-XR-X. 2 July 5, the root 42 is the root 05:16 /etc/cron.daily # system to perform regular daily tasks -rw -------. 1 root root 0. 11 dated 20 2018 /etc/cron.deny # blacklist drwxr-xr-x. 2 root root 22. 7 dated 11 20:28 /etc/cron.hourly # hour system . drwxr-xr-x 2 root root 6 . 6 dated 10 2014 /etc/cron.monthly # system month -rw-r - r -. 1 root root 451. 6 dated 10 2014 / etc / crontab # timer task master configuration file . drwxr-xr-x 2 root root 6 . 6 dated system week 10 2014 /etc/cron.weekly #
Regular tasks stored path
[root@nginx cron]# pwd /var/spool/cron
Timing task log
[root@nginx cron]# ll /var/log/cron -rw------- 1 root root 6744 8月 21 20:32 /var/log/cron
The timing of scheduled tasks configuration file parameters introduced
[the root @ Nginx the cron] # CAT / etc / the crontab the SHELL = / bin / the bash # timer task command interpreter PATH = / sbin: / bin: / usr / sbin: Environment Variables / usr / bin # command MAILTO = root # receive mail users
crontab command cron job main parameters:
-e # edit regular tasks
-l # View regular tasks
-r # delete the scheduled task file
-u # specify the user, the default is the current use
Examples :( a timing synchronization system time per minute)
install software:
[root@nginx ~]# yum -y install ntpdate
Manual testing whether the command can synchronize time
[root@nginx ~]# ntpdate ntp.aliyun.com 21 Aug 20:43:58 ntpdate[1930]: adjust time server 203.107.6.88 offset -0.002605 sec
Write regular tasks
[root@nginx cron]# crontab -e * * * * * ntpdate ntp.aliyun.com
Aug 21 20:50:01 nginx CROND[2257]: (root) CMD (ntpdate ntp.aliyun.com) Aug 21 20:51:01 nginx CROND[2311]: (root) CMD (ntpdate ntp.aliyun.com)
Regular tasks stored path
[root @ nginx cron] # pwd # file with your name / var / spool / cron