메뉴 닫기

anacrontab에 관하여

대다수 시간 동안 꺼져 있어야 하는 시스템은 anacron(anachronistic cron)이 적합하다.

anacron은 /var/spoo/anacron에 작업이 시작할 때를 기록한 타임스탬프 파일을 유지한다.

시스템이 켜져 anacron이 동작할 때, 작업이 마지막으로 수행해 흘러간 날짜를 살펴 필요하다면 작업을 수행한다.

그리하여 crontab 에 등록되어있는 백업 스케줄로 확인하였을시 이중백업이 되는 경우도 발생된다.

ex)

drwx—— 2 root root 4096 2015-05-21 03:16 20150521-03/
drwx—— 2 root root 4096 2015-05-21 04:02 20150521-04/

간단한 방법은 백업 스케줄링 실행파일을 cron.daily/ , cron.hourly/ , cron.monthly/ , cron.weekly/ 에 넣어서 cron 명령어를 통해 실행시킨다.

위와같이 3:16분 과 4:02분 이렇게 두차례에 걸쳐 백업이 진행된다.

위사항을 로그를 통해 살펴보게 된다면

May 21 03:16:01 localhost anacron[30752]: Job `cron.daily’ started
May 21 03:16:01 localhost run-parts(/etc/cron.daily)[30892]: starting cups
May 21 03:16:01 localhost run-parts(/etc/cron.daily)[30900]: finished cups
May 21 03:16:01 localhost run-parts(/etc/cron.daily)[30892]: starting dbbackup.sh
May 21 03:16:34 localhost run-parts(/etc/cron.daily)[30928]: finished dbbackup.sh
May 21 03:16:34 localhost run-parts(/etc/cron.daily)[30892]: starting logrotate
May 21 03:16:34 localhost run-parts(/etc/cron.daily)[30935]: finished logrotate
May 21 03:16:34 localhost run-parts(/etc/cron.daily)[30892]: starting makewhatis.cron
May 21 03:16:35 localhost run-parts(/etc/cron.daily)[31082]: finished makewhatis.cron
May 21 03:16:35 localhost run-parts(/etc/cron.daily)[30892]: starting mlocate.cron
May 21 03:16:44 localhost run-parts(/etc/cron.daily)[31093]: finished mlocate.cron
May 21 03:16:44 localhost run-parts(/etc/cron.daily)[30892]: starting prelink
May 21 03:16:44 localhost run-parts(/etc/cron.daily)[31105]: finished prelink
May 21 03:16:44 localhost run-parts(/etc/cron.daily)[30892]: starting readahead.cron
May 21 03:16:45 localhost run-parts(/etc/cron.daily)[31116]: finished readahead.cron
May 21 03:16:45 localhost run-parts(/etc/cron.daily)[30892]: starting time_sync.sh
May 21 03:16:48 localhost run-parts(/etc/cron.daily)[31126]: finished time_sync.sh
May 21 03:16:48 localhost run-parts(/etc/cron.daily)[30892]: starting tmpwatch
May 21 03:16:48 localhost run-parts(/etc/cron.daily)[31165]: finished tmpwatch
May 21 03:16:48 localhost anacron[30752]: Job `cron.daily’ terminated (mailing output)
May 21 03:16:48 localhost anacron[30752]: Normal exit (1 job run)

 

May 21 04:02:01 localhost CROND[32120]: (root) CMD (run-parts /etc/cron.daily)
May 21 04:02:01 localhost run-parts(/etc/cron.daily)[32120]: starting cups
May 21 04:02:01 localhost run-parts(/etc/cron.daily)[32128]: finished cups
May 21 04:02:01 localhost run-parts(/etc/cron.daily)[32120]: starting dbbackup.sh
May 21 04:02:35 localhost run-parts(/etc/cron.daily)[32186]: finished dbbackup.sh
May 21 04:02:35 localhost run-parts(/etc/cron.daily)[32120]: starting logrotate
May 21 04:02:35 localhost run-parts(/etc/cron.daily)[32193]: finished logrotate
May 21 04:02:35 localhost run-parts(/etc/cron.daily)[32120]: starting makewhatis.cron
May 21 04:02:37 localhost run-parts(/etc/cron.daily)[32340]: finished makewhatis.cron
May 21 04:02:37 localhost run-parts(/etc/cron.daily)[32120]: starting mlocate.cron
May 21 04:02:46 localhost run-parts(/etc/cron.daily)[32359]: finished mlocate.cron
May 21 04:02:46 localhost run-parts(/etc/cron.daily)[32120]: starting prelink
May 21 04:02:46 localhost run-parts(/etc/cron.daily)[32371]: finished prelink
May 21 04:02:46 localhost run-parts(/etc/cron.daily)[32120]: starting readahead.cron
May 21 04:02:46 localhost run-parts(/etc/cron.daily)[32382]: finished readahead.cron
May 21 04:02:46 localhost run-parts(/etc/cron.daily)[32120]: starting time_sync.sh
May 21 04:02:49 localhost run-parts(/etc/cron.daily)[32394]: finished time_sync.sh
May 21 04:02:49 localhost run-parts(/etc/cron.daily)[32120]: starting tmpwatch
May 21 04:02:49 localhost run-parts(/etc/cron.daily)[32432]: finished tmpwatch

anacron과 crond 두개를 통해 백업이 2번 진행되는점을 확인할수있다.

그리하여 anacron은 대다수 꺼져있어야 하는 시스템에 적합하며 실시간으로 켜져있어야하는 호스팅의경우에는 crond 를 통해 이용하면 된다.

그리하여 vi /etc/anacrontab 파일을 열어서 문제가되는 

1 5 cron.daily nice run-parts /etc/cron.daily 해당구문을 주석처리하면 된다.

그이후에 백업이 잘 되고있는지 확인한다.

 

[polldaddy rating=”7739789″]

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 항목은 *(으)로 표시합니다