cron - 주기적으로 실행될 작업 예약
at - 한번만 실행될 작업 예약

cron 서비스 데몬은 crond.
at 서비스 데몬은 atd.

crontab 형식 및 옵션

#crontab --help
usage: crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
-i (prompt before deleting user's crontab)

crontab 설정은 아래와 같다.

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

#--- 여기까지는 cron 작업을 위한 환경변수

# 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

#-- 여기는 주기적인 실행을 위한 설정 및 실행할 디렉토리.

형식:

분 시 일 월 요일 권한 실행명령 실행파일및 디렉토리

분: 0 ~ 59
시: 0 ~ 23
일: 1 ~ 31
월: 1 ~ 12
요일 : 0 ~ 6

예를 들면 아래내용은

22 4 * * 0 root run-parts /etc/cron.weekly

일요일 오전 4시 22분이 되면 root 권한으로 /etc/cron.weekly 에 있는 파일을 실행한다는 의미.

cron 사용 권한 설정

/etc/cron.allow 파일이 있는경우 cron.allow 에 기록이 된 사용자만 cron 을 사용할 수 있다.
/etc/cron.allow 이 없고 /etc/cron.deny 파일만 있는경우 /etc/cron.deny 에 기록이 안된 사용자만 cron을 사용할 수 있다.
두 파일이 모두 없으면 root 를 제외하고 아무도 cron을 사용할 수 없다.

EXAMPLE CRON FILE
# use /bin/sh to run commands, no matter what /etc/passwd says
SHELL=/bin/sh
# mail any output to 'paul', no matter whose crontab this is
MAILTO=paul
#
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun echo "run at 5 after 4 every sunday"

at

- 주기적으로 반복 실행할 수 없고 예약된 시간에 한번만 실행한다.

주요옵션

at -l ; 예약된 작업 보기
atq ; 예약된 작업보기
atrm ; 예약된 작업삭제하기

작업예약하기 형식

at 예약날짜 및 시간

ex) at 03pm
at 07am
at -t 0809201830 => 2008년 9월 20일 18시 38분 , -t 날짜 및 시간을 표기하기 위한 옵션
at now + 1 hour
at now + 10 min
at now + 2 days
at now + 1 hour -f /usr/sbin/poweroff => 1 시간뒤에 시스템을 끈다.(-f 는 실행파일명을 적기 위한 옵션)

ex 2)

[root@/]# at -t 09201830
at> httpd start
at> <EOT>
job 19 at 2008-09-20 18:30

at 사용권한 (man at 중에서...)

If the file /etc/at.allow exists, only usernames mentioned in it are allowed to use at.
If /etc/at.allow does not exist, /etc/at.deny is checked, every username not mentioned in it is then allowed to use at.
If neither exists, only the superuser is allowed use of at.
An empty /etc/at.deny means that every user is allowed use these commands, this is the default configuration.


'Log > Linux' 카테고리의 다른 글

파일시스템 생성작업  (0) 2011.11.28
리눅스 파일시스템 및 마운트  (0) 2011.11.28
process 관리  (0) 2011.11.28
파일 권한(Permission)  (0) 2011.11.28
계정관리  (0) 2011.11.28
Posted by logwatch

블로그 이미지
내가 나에게 확인 하는 블로그
logwatch

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2025.4
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

최근에 올라온 글

최근에 달린 댓글

글 보관함