Cron
#crontab [-u user] file
#crontab [-l | -r | -e]
restrict allow user
/etc/cron.allow (預設不存在, all user都允許, 除非黑名單deny, 才不允許使用)
/etc/cron.deny
1. user's crontab file
#crontab -e
a b c d e command-scripts
a: minute [0-59]
b: hour [0-23]
c: day of month [1-31]
d: month [1-12]
e: day of week [0-7, 0 or 7 = Sunday, 1=Monday]
2. system crontab file
#將需要執行的scripts放入目錄中, ex: cron.hourly/a.scripts. 每小時就會執行一次
/etc/cron.hourly/*
/etc/cron.daily/*
/etc/cron.weekly/*
/etc/cron/monthly/*
[root@server1 sysconfig]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
假設Sever並不是每天都開機(或停電)情況, 沒有執行到crontab file
在一開機時就會去執行 anacron system, 將沒做完的scripts繼續做完
[root@server1 cron.daily]# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
1 65 cron.daily run-parts /etc/cron.daily
7 70 cron.weekly run-parts /etc/cron.weekly
30 75 cron.monthly run-parts /etc/cron.monthly
field 1: not been run in this many days
field 2: wait this number of minutes after reboot and then run it
field 3: job identifer(描述)
field 4: job to run
- Jul 21 Tue 2009 23:24
[雜記]RHCE筆記整理-RH133-Unit4(6)
close
全站熱搜
留言列表