2007. 11. 3. 21:06 Unix

at으로 매일 실행하기

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2339 - May 28, 2006

                   
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

at으로 매일 실행하기

유닉스는 지정된 시간에 따라 작업을 실행할 수 있는 "at"이라는 명령어를 제공한다.

특정한 작업을 매시간, 매일 실행하기 위해서는 매일 재귀적으로 실행될 수 있는
"at.sh"라는 파일에 다음의 명령어들을 사용하라.

########### CUT HERE ##################

#! /usr/bin/sh

# dt는 현재 날짜를 저장하는데 사용하는 변수

dt=`date | cut -c5-10`

# tm은 현재 시간을 저장하는데 사용하는 변수

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

#
"at"은 명령어이고 -f는 특정파일을 실행하는데 사용하는 옵션이다.
# "file Name"은 실행가능한 파일이어야 한다.

    at -f  ./"file Name" $tm $dt
    tm=`expr $tm + 1`
done

#
인위적인 개입없이, 자동으로 다음날의 작업 스케줄을 변경한다.

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################
 
@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
 
RUN DAILY WITH AT

UNIX provides a command called "at" which can be used to run jobs according
to the specfied time.

To run a particular job in every hour, every day use the following set of
commands in a file called "at.sh" which will be executed recursively everyday.

########### CUT HERE ##################

#! /usr/bin/sh

# dt is a variable used to store current date

dt=`date | cut -c5-10`

# tm is a variable used to store current time

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

# "at" is the command ad -f is the option used to execute a specified
# file. "file Name" should be an executable file.

 at -f  ./"file Name" $tm $dt
 tm=`expr $tm + 1`
done

# With out manual intervention, automatic change over to the next day's job
# scheduling

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################
반응형
Posted by She쥐포s

블로그 이미지
She쥐포s
Yesterday
Today
Total

달력

 « |  » 2024.3
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
31

최근에 올라온 글

최근에 달린 댓글

글 보관함