CentOS下CronTab任务周期计划详解

2020-01-30 15:48:14王旭

HOME=/

# 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

[root@nagios ~]# ll /var/spool/cron/

total 8

-rw------- 1 root   root   60 Apr  2 01:33 root

-rw------- 1 zwhset zwhset 68 Apr  2 01:51 zwhset

[root@nagios ~]# tail -5 /var/log/cron

Apr  2 17:24:01 nagios CROND[20544]: (root) CMD (/bin/sh ~/hello)

Apr  2 17:25:01 nagios CROND[20549]: (root) CMD (/bin/sh ~/hello)

Apr  2 17:25:01 nagios CROND[20550]: (root) CMD (/bin/sh ~/hello)

Apr  2 17:25:01 nagios CROND[20551]: (zwhset) CMD (echo "hello" >> ~/1.txt)

Apr  2 17:25:01 nagios CROND[20552]: (zwhset) CMD (echo "hello" >> ~/1.txt)

[root@nagios ~]# ps aux |grep cron

root      2074  0.0  0.5 117212  1316 ?        Ss   01:40   0:04 crond

root     20641  0.0  0.6 139684  1468 pts/1    S+   17:30   0:00 crontab -e

zwhset   20642  0.0  0.7 119284  1756 pts/1    S+   17:30   0:00 /bin/vi /tmp/crontab.YphQpH

root     20663  0.0  0.3 103236   856 pts/0    S+   17:31   0:00 grep cron

[root@nagios ~]# lsof -c crontab

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF   NODE NAME

crontab 20641 root  cwd    DIR              253,0     4096 130818 /root

crontab 20641 root  rtd    DIR              253,0     4096      2 /

crontab 20641 root  txt    REG              253,0    47520 401259 /usr/bin/crontab

crontab 20641 root  mem    REG              253,0     5952 261889 /lib64/security/pam_deny.so

crontab 20641 root  mem    REG              253,0    18592 261891 /lib64/security/pam_env.so

crontab 20641 root  mem    REG              253,0    18592 261903 /lib64/security/pam_limits.so

crontab 20641 root  mem    REG              253,0    10224 261901 /lib64/security/pam_keyinit.so

crontab 20641 root  mem    REG              253,0    10240 261906 /lib64/security/pam_loginuid.so