crontab使用小結

在linux 和unix系統上都有crontab 命令來進行定時任務的調度,不過對於一些文件和日誌的位置有所區別:

首先講下crontab的參數

usage: crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
-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)

對於crontab定時任務的調度是依靠crond守護進程來完成的,參數爲:

Usage: /etc/init.d/crond  {start|stop|status|reload|restart|condrestart}

一個 crontab 文件包含每個 cron 作業的條目。條目由換行字符分開。每個 crontab 文件條目包括 6 個字段,它們被空格或製表符以以下格式分開:

minute hour day_of_month month weekday command這些字段接收以下值:
minute 0 到 59
hour 0 到 23
day_of_month 1 到 31
month 1 到 12
weekday 0 到 6 (星期日到星期六)
command shell 命令

eg:30 23 * * * command 表示每天23點30時分執行command任務。

在linux下:/var/spool/cron/<user>文件,是crontab文件,/var/log/cron文件是crontab運行的一些log

在unix下:/var/spool/cron/crontabs/<user>文件,是crontab文件,/var/adm/cron/cron.allow文件是有crontab權限的用戶


詳情參看:

http://blog.csdn.net/sun93732/article/details/6045050

http://blog.csdn.net/hittata/article/details/7713072


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章