Centos 6.x crond (anacron) > 주인장(개발자) 로그 - [Unknown]

본문 바로가기
사이트 내 전체검색
google.com / youtube.com / naver.com / daum.net / zum.com


현재: 약 50만 다운로드 / 목표: 글로벌 5,000만 다운로드 이상
인기 국가: 한국,인도,미국,홍콩,오스트리아,일본,스위스
프랑스,캐나다,이탈리아,오스트레일리아,영국,스페인

회원로그인


이곳은 "개인 블로그"입니다.
::: 손님분들 환영 :::
콜린스코빌드 영영사전
캠브리지 영영사전
옥스포드 영영사전
메리엄웹스터 영영사전
롱맨 영영사전
특수문자
2024-04-20 ()
17:16 KST / +09:00
Give First, and then ...

[ Android Application Links ]
Since 2011.03

ⓐ 정각알림(OnTimeAlarm)
ⓑ 알람포미(Alarm4Me)
ⓒ 플래시온(FlashOn)
ⓓ 와이파이온오프위젯
    (WifiOnOff4 Widget)

ⓔ 폴더플레이어포미
    (FolderPlayer4Me)

ⓕ 리코더포미(Recorder4Me)
ⓖ 리사이즈픽포미
    (ResizePic4Me)

ⓗ 언인스톨러포미
    (Uninstaller4Me)

ⓘ 배터리포미(Battery4Me)
ⓙ 볼륨맨포미
    (Volumeman4Me)

달러 환율보기
Your IP: 3.22.181.209

배너수익은 앱개발과 개선에 사용합니다.

※ 주인장의 개인 글쓰기 공간 

 

주인장(개발자) 로그

Linux | Centos 6.x crond (anacron)

페이지 정보

작성자 주인장 작성일2016. 06. 30. 00:56 조회23,440회 댓글0건

본문



배너수익은 앱개발과 개선에 사용합니다.

[Centos 6.x crond (anacron)]

 

[root@localhost ~]# yum install crontabs

 

[root@localhost ~]# cat /etc/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

[root@localhost ~]#

 

[root@localhost ~]# ls -l /etc/cron.d

total 8

-rw-r--r--  1 root root 113 Nov 10  2015 0hourly

-rw-r--r--. 1 root root 108 Oct 11  2013 raid-check

[root@localhost ~]#

[root@localhost ~]# cat /etc/cron.d/0hourly
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
01 * * * * root run-parts /etc/cron.hourly
[root@localhost ~]#

[root@localhost ~]# ls -l /etc/cron.hourly/
total 8
-rwxr-xr-x  1 root root 409 Nov 10  2015 0anacron
-rwxr-xr-x. 1 root root 273 Nov 22  2013 mcelog.cron
[root@localhost ~]#

[root@localhost ~]# cat /etc/cron.hourly/0anacron
#!/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
[root@localhost ~]#

[root@localhost ~]# 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
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1       5       cron.daily              nice run-parts /etc/cron.daily
7       25      cron.weekly             nice run-parts /etc/cron.weekly
@monthly 45     cron.monthly            nice run-parts /etc/cron.monthly
[root@localhost ~]#

$–> Field 1 is Recurrence period: This is a numeric value that specifies the number of days.
1 – daily
7 – weekly
30 – monthly
N – This can be any numeric value. N indicates number of days
@monthly’ for a job that needs to be executed monthly.

$–> Field 2 is Delay: This indicates the delay in minutes. i.e X number of minutes anacron should wait before executing the job after the the machine starts.

$–> Field 3 is Job identifier: It is the name for the job’s timestamp file. It should be unique for each job. This will be available as a file under the /var/spool/anacron directory. This file will contain a single line that indicates the last time when this job was executed.

$–> Field 4 is command: Command or shell script that needs to be executed.

START_HOURS_RANGE :- Interval, when scheduled jobs can be run, in hours, In case the time interval is missed, for example due to a power failure, the scheduled jobs are not executed that day.

RANDOM_DELAY :- maximum number of minutes that will be added to the delay in minutes variable which is specified for each job, The minimum delay value is set, by default, to 6 minutes. If RANDOM_DELAY is, for example, set to 12, then between 6 and 12 minutes are added to the delay in minutes for each job in that particular anacrontab. RANDOM_DELAY can also be set to a value below 6, including 0. When set to 0, no random delay is added. This proves to be useful when, for example, more computers that share one network connection need to download the same data every day.

[anacron 은 왜 도입되었나?]
1) 작업이 시작되는 시간을 매번 0분~45분 지연시켜 다른 서버들과 동일한 시간에 스케쥴 작업이 실행되는 부담을 줄인다.

기존 cron 에서는 /etc/cron.daily 를 매일 새벽 4시 2분에 실행하는 것이 기본값이었다. 만약 이 상황에서 rdate로 시간동기화를 time.bora.net으로 하도록 해두었다면 time.bora.net으로 새벽 4시 2분에 수많은 서버에서 동시요청을 하기 때문에 거의 DDOS 공격에 해당하게 되어 제대로 접속이 어려울 수 있다. 시간 동기화 외에도 VM이나 공유 스토리지를 사용하는 경우에도 모든 장비가 동시간에 부하가 발생하는 작업을 처리하는 것은 매우 비효율적일 것이다.  이러한 문제를 해결하는데 도움이 된다.
0분~45분 지연 시간은 /etc/anacrontab  설정의 RANDOM_DELAY=45 항목을 통해 변경할 수 있다.

2) 서버의 정지/장애 등으로 인한 매일/매주/매월 자동 실행 작업의 누락 가능성을 줄여준다.
이 부분은 자동 스케쥴러가 다소 복잡한 환경에서 유리하며 보다 자세한 내용을 알고 싶으신 분들은 다음 블로그 글을 참고한다.


  • 페이스북으로 보내기
  • 트위터로 보내기
  • 구글플러스로 보내기

댓글목록

등록된 댓글이 없습니다.

주인장(개발자) 로그 목록

Total 221건 7 페이지
주인장(개발자) 로그 목록
번호 제목 글쓴이 날짜 조회
161 Talk 포브스 '혁신적 기업' 순위서 네이버 9위 인기글관련링크

미국 경제 전문지 포브스가 선정한 혁신적 기업 100대 순위에서 네이버가 9위를 차지했다. 한국 기업 4개가 이름을 올렸다.  ...
주인장 06. 07 19235
160 Talk Shallows, Shark 인기글

Shallows, Shark  ...
주인장 09. 15 19168
159 채근담 채근담 전집22 인기글

채근담 전집22 움직이기를 좋아하는 이는 구름 속에서 번쩍이는 번개와 바람 앞에서 흔들리는 등불과 같고, 고요함을 즐기는 이...
주인장 07. 09 19081
158 채근담 채근담 전집26 인기글

채근담 전집26 배부른 뒤에 음식맛을 생각하면 곧 기름진 맛과 담백한 맛의 구별을 할 수 없고, 정사(情事)를 가진 후에 정...
주인장 07. 09 19050
157 Talk 터널 - 하정우, 오달수 인기글

터널 - 하정우, 오달수  ...
주인장 09. 16 18885
156 Talk 비슬산 둘레길 인기글

비슬산 둘레길 ...
주인장 12. 11 18874
155 Talk 9월 11일 - godaddy 쿠폰으로 도메인 구매, 1299원(1년) 인기글

2016년 9월 11일godaddy 쿠폰을 사용해 greatdragonkim.com 도메인을 1299원(1년)에 구매...
주인장 09. 14 18839
154 Talk 델모니터 25인치 U2515H WQHD 2560x1440 인기글

Dell U2515H Monitor WQHD  2560x1440 ...
주인장 09. 11 18829
153 Talk 브렉시트 인기글관련링크

브렉시트=====BRitain + EXIT : - BREXIT. 영국이 유럽연합에서 탈퇴할 수 있다는 데서 나온 말. 이런 ...
주인장 06. 24 18818
152 채근담 채근담 전집8 인기글

채근담 전집8 하늘과 땅은 고요하여 움직이지 않지만 그 작용에는 잠시의 휴식이 없고, 해와 달은 밤낮으로 달리고 있지만 그 ...
주인장 07. 09 18796
게시물 검색


접속자집계

오늘
3,237
어제
4,011
최대
8,785
전체
8,979,756
* LOG :: ① 배의 속력이나 항정(航程)을 재는 데 쓰는 항해 계기 ② 항해 일지나 항공 일지 :: From 2016. About me 상단으로
안드로이드 애플리케이션 테스트에 사용하고 있는 스마트폰들
Galaxy Folder2(Android 6.0), Galaxy S10+(Android 11), LG V50(Android 10), Galaxy S9+(Android 10), Redmi Note7(Android 9)
Galaxy S7(Android 8.0), Galaxy S5(Android 6.0), Nexus 5x(Android 8.1), G4(Android 7.0), Redmi 4 Prime(Android 6.0)
모바일 버전으로 보기