seeyou 2011-11-2 11:41
修改CentOS 6.0 版本的 Crontab logrotate 的時間
<P>在CentOS 6.0 下,Apache Log 每次 rotate 的時間, 都是早上 3~22, 要修改 Log Rotate 的時間, 要從哪改呢?<BR><BR>Red Hat Enterprise Linux 6 includes the cronie package as a replacement for vixie-cron. The main difference between these packages is how the regular jobs (daily, weekly, monthly) are done. Cronie uses the /etc/anacrontab file, which by default looks like the following:</P>
<P> </P>
<P>[quote]</P>
<P># the maximal random delay added to the base delay of the jobs<BR>RANDOM_DELAY=45</P>
<P> </P>
<P># the jobs will be started during the following hours only<BR>START_HOURS_RANGE=3-22</P>
<P> </P>
<P># period in days delay in minutes job-identifier command<BR>1 5 cron.daily nice run-parts /etc/cron.daily<BR>7 25 cron.weekly nice run-parts /etc/cron.weekly<BR>@monthly 45 cron.monthly nice run-parts /etc/cron.monthly<BR>[/quote]</P>
<P> </P>
<P>These regular jobs will be executed once a day in the 03:00-22:00 time interval, including a random delay. For example, cron.daily will have a 5 minute forced delay plus a random delay of 0-45 minutes. You could also run jobs with no delays, between 8 and 9:</P>
<P> </P>
<P>[quote]</P>
<P>RANDOM_DELAY=0 # or don't use this option at all<BR>START_HOURS_RANGE=8-9</P>
<P> </P>
<P># period in days delay in minutes job-identifier command<BR>1 0 cron.daily nice run-parts /etc/cron.daily<BR>7 0 cron.weekly nice run-parts /etc/cron.weekly<BR>@monthly 0 cron.monthly nice run-parts /etc/cron.monthly<BR>[/quote]</P>
<P> </P>
<P>如果你不想使用預設的 cronie-anacron ...那你也可以改用別的套件...</P>
<P>if you want more fine grained control you could just ditch anacron altogether and use <FONT color=red>/etc/cron.d/dailyjobs</FONT> </P>
<P> </P>
<P>[quote]</P>
<P><FONT color=red>yum remove cronie-anacron<BR>yum install cronie-noanacron sysstat</FONT></P>
<P>[/quote]</P>
<P> </P>
<P>不要忘記 start crond</P>
<P>[quote]</P>
<P>service crond start<BR>chkconfig crond on</P>
<P>[/quote]</P>
<P> </P>
<P><FONT color=#ff0000><FONT color=black>再檢查一下</FONT> /etc/cron.d/dailyjobs</FONT><FONT color=black> 這個設定檔就出現啦~~</FONT></P>