centos:cron_anacron_on_centos6
目次
CentOS6のcronとanacronの処理
初期の配置
/ └── etc ├── cron.d │ └── 0hourly : 毎時1分に /etc/cron.hourly 以下を実行 ├── cron.daily │ └── logrotate ├── cron.deny ├── cron.hourly │ └── 0anacron : anacron 実行 ├── cron.monthly │ └── ├── cron.weekly │ └── └── crontab : 初期値は空
各ファイル
/etc/crontab
システムの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
/etc/cron.d/0hourly
毎時1分にcron.hourlyを実行
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ 01 * * * * root run-parts /etc/cron.hourly
/etc/cron.hourly/0anacron
一時間ごとにanacronを起動
#!/bin/bash # Skip excecution unless the date has changed from the previous run if test -r /var/spool/anacron/cron.daily; then day=`cat /var/spool/anacron/cron.daily` fi if [ `date +%Y%m%d` = "$day" ]; then exit 0; fi # Skip excecution unless AC powered if test -x /usr/bin/on_ac_power; then /usr/bin/on_ac_power &> /dev/null if test $? -eq 1; then exit 0 fi fi /usr/sbin/anacron -s
/etc/anacrontab
anacronが/etc/cron.(daily|weekly|monthly)を実行
# /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="" 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
centos/cron_anacron_on_centos6.txt · 最終更新: 2014/11/12 04:30 by clownclown