十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
CronTab 任務(wù)周期計劃

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:域名注冊、雅安服務(wù)器托管、營銷軟件、網(wǎng)站建設(shè)、臺州網(wǎng)站維護、網(wǎng)站推廣。
| * * * * * command
分(0-59)、時(0-23)、日(1-31)、月(1-12)、周(0-6) |
| 1、星號可以匹配所有字符
2、一個整數(shù)、必須精確匹配 3、用短劃線隔開的兩個整數(shù),它們匹配的是值的范圍。 4、時間范圍后加斜扛和一個步長值。1-10/2 |
| crontab --help
crontab -e #檢出一個crontab副本,調(diào)用vi編輯它,并重新保存在crontab目錄。 crontab -l #將crontab的內(nèi)容打印到標(biāo)準(zhǔn)輸出。 crontab -r #冊除并不留任何內(nèi)容。 |
| [root@nagios ~]# crontab --help
crontab: invalid option -- '-' crontab: usage error: unrecognized option usage:crontab [-u user] file crontab [-u user] [ -e | -l | -r ] (default operation is replace, per 1003.2) -e(edit user's crontab) -l(list user's crontab) -r(delete user's crontab) -i(prompt before deleting user's crontab) -s(selinux context) [root@nagios ~]# ll /usr/bin/crontab -rwsr-xr-x 1 root root 47520 Jul 19 2011 /usr/bin/crontab [root@nagios ~]# cat /var/run/crond.pid 2074 [root@nagios ~]# ll /etc/ |grep -E cron drwxr-xr-x 2 root root 4096 Apr 2 00:59 cron.d drwxr-xr-x. 2 root root 4096 Sep 27 2011 cron.daily -rw-r--r-- 1 root root 0 Jul 19 2011 cron.deny drwxr-xr-x 2 root root 4096 Sep 27 2011 cron.hourly drwxr-xr-x 2 root root 4096 Sep 27 2011 cron.monthly -rw-r--r-- 1 root root 457 Sep 27 2011 crontab drwxr-xr-x 2 root root 4096 Sep 27 2011 cron.weekly [root@nagios ~]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root 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 crontab 20641 root mem REG 253,0 6040 261912 /lib64/security/pam_permit.so crontab 20641 root mem REG 253,0 14384 261923 /lib64/security/pam_succeed_if.so crontab 20641 root mem REG 253,0 10200 261905 /lib64/security/pam_localuser.so crontab 20641 root mem REG 253,0 51952 261929 /lib64/security/pam_unix.so crontab 20641 root mem REG 253,0 113432 261657 /lib64/libnsl-2.12.so crontab 20641 root mem REG 253,0 14456 261884 /lib64/security/pam_access.so crontab 20641 root mem REG 253,0 65928 261663 /lib64/libnss_files-2.12.so crontab 20641 root mem REG 253,0 99158576 397021 /usr/lib/locale/locale-archive crontab 20641 root mem REG 253,0 383504 261640 /lib64/libfreebl3.so crontab 20641 root mem REG 253,0 40400 261651 /lib64/libcrypt-2.12.so crontab 20641 root mem REG 253,0 1916568 261647 /lib64/libc-2.12.so crontab 20641 root mem REG 253,0 113096 261709 /lib64/libaudit.so.1.0.0 crontab 20641 root mem REG 253,0 19536 261653 /lib64/libdl-2.12.so crontab 20641 root mem REG 253,0 55848 261879 /lib64/libpam.so.0.82.2 crontab 20641 root mem REG 253,0 122040 261718 /lib64/libselinux.so.1 crontab 20641 root mem REG 253,0 154464 261636 /lib64/ld-2.12.so crontab 20641 root 0u CHR 136,1 0t0 4 /dev/pts/1 crontab 20641 root 1u CHR 136,1 0t0 4 /dev/pts/1 crontab 20641 root 2u CHR 136,1 0t0 4 /dev/pts/1 crontab 20641 root 3u unix 0xffff88000225c380 0t0 91831 socket crontab 20641 root 5u REG 253,0 68 916745 /tmp/crontab.YphQpH |