at 명령어 (AIX 5.3·6.1)

핵심 정리

  • 나중에 실행할 명령을 표준 입력(또는 -f 파일)에서 읽어 정한 시각에 한 번 실행합니다. 입력을 마치면 Ctrl-D를 누릅니다.
  • 시각은 at 5 pm Friday, at 1500 jan 24, at now + 2 days, at now next week처럼 쓰거나 -t [[CC]YY]MMDDhhmm[.SS]로 지정합니다.
  • 출력은 재지정하지 않으면 메일로 옵니다. 작업 번호와 예정 시각은 표준 오류에 씁니다. 현재 환경은 유지하지만 열린 파일, 트랩, 우선순위는 유지하지 않습니다.
  • -l은 예약 목록, -r 작업은 삭제, -m은 실행 성공을 메일로 알림, -k·-c·-s는 ksh·csh·bsh로 실행합니다.
  • 큐: a(at, 기본), b(batch), c(cron), d(sync), e(ksh), f(csh), g~z(사용자 정의).
  • 사용 권한은 /var/adm/cron/at.allow와 at.deny가 정합니다. 둘 다 없으면 root만 쓸 수 있습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (6.1에서 큐당 60개 제한이 없어지고, 2038~2105년을 yyyy로 쓰는 설명과 RBAC 문단이 더해짐)
원문 IBM Commands Reference — 5.3 Volume 1, 6.1 Volume 1
파일 /usr/bin/at, /var/spool/cron/atjobs, /var/adm/cron/at.allow, /var/adm/cron/at.deny
관련 명령어 batch, atrm, cron, crontab

목적

나중에 실행할 작업을 예약합니다.

영어 원문

Runs commands at a later time.

구문

나중에 실행할 작업을 예약할 때:

text
at [ -c | -k | -s | -q Queue ] [ -m ] [ -f File ] { -t Date | Time [ Day ] [ Increment ] }

예약한 작업을 볼 때:

text
at -l [ -v ] [ -o ] [ Job ... | -q Queue ]
at -n [ User ]

예약한 작업을 지울 때:

text
at -r [ -F ] [ -i ] Job ...
at -r [ -F ] [ -i ] -u User

설명

at 명령은 나중에 실행할 명령의 이름을 표준 입력에서 읽고, 그 명령을 언제 실행할지 지정하게 합니다.

예약한 명령의 표준 출력과 표준 오류는 재지정하지 않으면 모두 메일로 보냅니다. 작업 번호와 예정 시각은 표준 오류에 씁니다.

at을 실행할 때의 현재 프로세스 환경은 유지되지만, 열린 파일 기술자, 트랩, 우선순위는 유지되지 않습니다.

사용 제한

/var/adm/cron/at.allow와 /var/adm/cron/at.deny 파일이 at을 쓸 수 있는 사용자를 정합니다. root 권한이 있는 사람이 이 파일을 만들고 고치고 지웁니다. 항목은 한 줄에 하나씩 쓴 로그인 이름입니다(예: root, nick, dee, sarah를 한 줄씩).

  • at.allow가 있으면 그 안에 로그인 이름이 있는 사용자만 쓸 수 있습니다.
  • 관리자는 at.deny에 로그인 이름을 적어 그 사용자가 쓰지 못하게 할 수 있습니다. at.deny만 있으면 거기에 없는 모든 사용자가 쓸 수 있습니다.
  • at.allow와 at.deny가 둘 다 없거나, at.allow에 이름이 없거나, at.deny에 이름이 있으면 쓸 수 없습니다. 둘 다 없으면 root 권한이 있는 사용자만 쓸 수 있습니다.

시각 지정

작업을 예약하려면 시작 시각을 지정해야 합니다. -t Date 플래그나 Time, Day, Increment 매개변수로 지정합니다. 6.1 문서는 "초당 최대 60개의 단위로 원하는 만큼 작업을 예약할 수 있다"고 합니다(5.3은 큐마다 최대 60개, 넘으면 /var/spool/cron/atjobs/_at<pid> 파일이 생긴다고 설명).

-t의 Date 형식은 [[CC]YY]MMDDhhmm[.SS]입니다.

자리 뜻
CC 연도의 앞 두 자리(세기)
YY 연도의 뒤 두 자리
MM 월(01~12)
DD 일(01~31)
hh 시(00~23)
mm 분(00~59)
SS 초(00~59). 기본은 00
  • CC와 YY는 선택이며, 둘 다 없으면 올해입니다. YY만 주면 7099는 19, 0037은 20을 CC로 봅니다.
  • (6.1) 2038년부터 2105년까지는 연도를 yyyy 형식으로 지정합니다.
  • 결과 시각은 TZ 환경 변수의 영향을 받습니다.

Time 매개변수는 숫자와 선택 접미사로 씁니다.

  • 한두 자리 숫자는 시, 네 자리는 시와 분으로 해석합니다. 시와 분의 순서는 LC_TIME 로캘 범주의 T_FMT가 정하며 기본은 시·분입니다. 시와 분을 :(쌍점)으로 나눌 수도 있습니다.
  • 접미사 am, pm, zulu를 붙일 수 있습니다. am이나 pm이 없으면 24시간제입니다. am·pm은 LC_TIME의 AM_STR·PM_STR 값이며, zulu는 GMT를 뜻합니다.
  • 특별한 값으로 noon, midnight, now, A(AM), P(PM), N(정오), M(자정)을 씁니다.

Day 매개변수(선택)는 월 이름과 날짜(쉼표 뒤에 연도를 붙일 수 있음)나 요일로 씁니다. 월과 일의 순서는 LC_TIME의 D_FMT가 정하며 기본은 월·일입니다. 요일과 월의 긴 이름·짧은 이름은 LC_TIME의 DAY_1DAY_7, ABDAY_1ABDAY_7, MON_1MON_12, ABMON_1ABMON_12가 정합니다. 기본으로 긴 이름은 전체를 쓰고, 짧은 이름은 요일은 두 글자 이상, 월은 세 글자로 줄입니다.

Day의 특별한 기본값으로 today와 tomorrow가 있습니다. 지정한 시각이 지금 시보다 늦으면 today, 이르면 tomorrow가 기본입니다. 지정한 월이 이번 달보다 앞이고 연도가 없으면 내년이 기본입니다.

영어 원문

The at command reads from standard input the names of commands to be run at a later time and allows you to specify when the commands should be run.

The at command mails you all output from standard output and standard error for the scheduled commands, unless you redirect that output. It also writes the job number and the scheduled time to standard error.

When the at command is executed, it retains the current process environment. It does not retain open file descriptors, traps, and priority.

The /var/adm/cron/at.allow and /var/adm/cron/at.deny files control what users can use the at command. A person with root user authority can create, edit, or delete these files. Entries in these files are user login names with one name to a line. The following is an example of an at.allow file: root nick dee sarah

If the at.allow file exists, only users whose login names appear in it can use the at command. A system administrator can explicitly stop a user from using the at command by listing the user's login name in the at.deny file. If only the at.deny file exists, any user whose name does not appear in the file can use the at command.

A user cannot use the at command if one of the following is true:

  • The at.allow file and the at.deny file do not exist (allows root user only).

  • The at.allow file exists but the user's login name is not listed in it.

  • The at.deny file exists and the user's login name is listed in it.

If the at.allow file does not exist and the at.deny file does not exist, only users with root authority can submit a job with the at command.

To schedule a job to run later, you must specify a time to start the job. You might specify the time by using either the -t Date flag or the Time, Day, and Increment parameters. You can schedule any number of jobs at maximum granularity of 60 per second.

The Date variable to the -t flag is specified using the following format:

[[CC]YY]MMDDhhmm[.SS]

The digits in the Date variable are defined as follows:

  • CC — Specifies the first two digits of the year (the century).
  • YY — Specifies the second two digits of the year.
  • MM — Specifies the month of the year (01 through 12).
  • DD — Specifies the day of the month (01 through 31).
  • hh — Specifies the hour of the day (00 through 23).
  • mm — Specifies the minute of the hour (00 through 59).
  • SS — Specifies the second of the minute (00 through 59).

Both the CC and YY digits are optional. If neither is given, the current year is assumed. If the YY digits are specified but the CC digits are not, the CC digits are defined as follows:

  • If the value of the YY digits is between 70 and 99, the value of the CC digits is assumed to be 19.

  • If the value of the YY digits is between 00 and 37, the value of the CC digits is assumed to be 20.

  • The default value of SS is 00. For years between 2038 and 2105, specify year in the yyyy format.

The resulting time is affected by the value of the TZ environment variable.

The Time parameter may be specified as a number followed by an optional suffix. The at command interprets one- and two-digit numbers as hours. It interprets four digits as hours and minutes. The T_FMT item in the LC_TIME locale category specifies the order of hours and minutes. The default order is the hour followed by the minute. You can also separate hours and minutes with a : (colon). The default order is Hour:Minute.

In addition, you may specify one of the following suffixes:

  • am

  • pm

  • zulu

If you do not specify am or pm, the at command uses a 24-hour clock. These suffixes can follow the time as a separate argument or separated with spaces. The am and pm suffixes are defined values from the AM_STR and PM_STR items in the LC_TIME locale category. The suffix zulu indicates that the time is GMT (Greenwich Mean Time).

The at command also recognizes the following keywords as special values for the Time parameter:

  • noon

  • midnight

  • now

  • A for AM

  • P for PM

  • N for noon

  • M for midnight

You may specify the optional Day parameter as either a month name and a day number (and possibly a year number preceded by a comma), or a day of the week. The D_FMT item in the LC_TIME locale category specifies the order of the month and day (by default, month followed by day). The DAY_1 through DAY_7 items in the LC_TIME locale category specify long day names. The ABDAY_1 through ABDAY_7 items in the LC_TIME locale category specify short day names. The MON_1 through MON_12 items in the LC_TIME locale category specify long month names. The ABMON_1 through ABMON_12 items in the LC_TIME locale category specify short month names. By default, the long name is fully spelled out; the short name is abbreviated to two or more characters for weekdays, and three characters for months.

The at command recognizes today and tomorrow as special default values for the Day parameter. The today value is the default Day if the specified time is later than the current hour; the tomorrow value is the default if the time is earlier than the current hour. If the specified month is less than the current month (and a year is not given), next year is the default year.

플래그

플래그 설명
-c 이 작업을 csh로 실행합니다.
-f File 표준 입력 대신 지정한 파일을 입력으로 씁니다.
-F 삭제 확인을 하지 않습니다. -r과 함께 씁니다.
-i 대화형으로 지웁니다. -r과 함께 씁니다.
-k 이 작업을 ksh로 실행합니다.
-l 예약한 작업을 보고합니다. root 권한이 있으면 다른 사용자의 작업도 볼 수 있습니다.
-m 명령이 잘 실행되면 사용자에게 메일을 보냅니다.
-n [User] 자신이나 사용자의 큐에 있는 파일 수를 보고합니다.
-o 예정 순서대로 작업을 나열합니다. -l과 함께 쓸 때만 쓸모가 있습니다.
-q Queue 작업을 넣을 큐를 지정합니다. -l과 함께 쓰면 그 큐로 보고를 제한합니다(아래 표).
-r Job... at이나 batch로 예약한 작업을 지웁니다. Job은 at·batch가 매긴 번호입니다. root 권한이 없으면 자기 작업만 지울 수 있습니다. root는 atrm 명령으로 다른 사용자의 작업이나 특정 사용자의 모든 작업을 지울 수 있습니다.
-s 이 작업을 bsh(Bourne 셸)로 실행합니다.
-t Date Date로 지정한 시각에 실행하도록 작업을 등록합니다.
-u User 지정한 사용자의 모든 작업을 지웁니다. -r과 함께 쓸 때는 Job을 지정하지 않습니다(at -r -u User).
-v -l과 함께 써서 나열한 작업의 내용을 보여 줍니다.

-q의 큐:

큐 쓰임
a at 작업(기본)
b batch 작업. batch 명령이 이 플래그로 at을 부릅니다. b 큐는 명령을 표준 입력에서 읽고, 명령줄에 무엇을 지정하든 Time은 now입니다.
c cron 작업(예약됨)
d sync 작업(예약됨)
e ksh 작업(-k와 같음)
f csh 작업(-c와 같음)
g~z 사용자 정의 큐
영어 원문
  • -c — Requests that the csh command be used for executing this job.
  • -f File — Uses the specified file as input rather than using standard input.
  • -F — Suppresses delete verification. Use this flag with the -r flag.
  • -i — Specifies interactive delete. Use this flag with the -r flag.
  • -k — Requests that the ksh command be used for executing this job.
  • -l — Reports your scheduled jobs. If you have root user authority, you can get jobs issued by other users.
  • -m — Mails a message to the user about the successful execution of the command.
  • -n [ User ] — Reports the number of files in your queue or user's queue.
  • -o — Lists jobs in schedule order. This flag is useful only with the -l flag.
  • -q Queue — Specifies the queue in which to schedule a job for submission. When used with the -l flag, the report is limited to the queue specified by the Queue variable. By default, at jobs are scheduled in the a queue. The b, c and d queues are reserved for batchjobs, cron jobs, and sync jobs respectively. -q a Queues at jobs. -q b Queues batch jobs. The batch command calls the at command with this flag. Note: When using the b queue, commands are read from standard input. Also, the now keyword is used for the Time parameter, regardless of what you specify on the command line. -q e Queues ksh jobs. Equivalent to the -k flag. -q f Queues csh jobs. Equivalent to the -c flag. -q g-z Queues user defined queue jobs.
  • -r Job... — Removes Jobs previously scheduled by the at or batch commands, where Job is the number assigned by the at or batch commands. If you do not have root user authority (see the su command), you can remove only your own jobs. The atrm command is available to the root user to remove jobs issued by other users or all jobs issued by a specific user.
  • -s — Requests that the bsh command (Bourne shell) be used for executing this job.
  • -t Date — Submits the job to be run at the time specified by the Date variable.
  • -u User — Deletes all jobs for the specified user. If used with the -r flag, do not specify a Job variable (the correct syntax is at -r -u User).
  • -v — Used with -l flag to show content of listed jobs.

매개변수

매개변수 설명
Day 월 이름과 날짜(쉼표 뒤 연도 가능)나 요일로 지정합니다.
Increment 다음 중 하나입니다. +(더하기)와 숫자 뒤에 minute[s], hour[s], day[s], week[s], month[s], year[s] 중 하나, 또는 특별한 단어 next 뒤에 같은 단어 중 하나.
영어 원문
  • Day — Specifies the optional Day parameter as either a month name and a day number (and possibly a year number preceded by a comma), or a day of the week.

  • Increment — The optional Increment parameter can be one of the following:

  • A + (plus sign) followed by a number and one of the following words: – minute[s] – hour[s] – day[s] – week[s] – month[s] – year[s]

  • The special word next followed by a one of the following words: – minute[s] – hour[s] – day[s] – week[s] – month[s] – year[s]

보안

감사 서브시스템이 알맞게 설정되고 켜져 있으면, at은 실행할 때마다 다음 감사 레코드(이벤트)를 만듭니다.

이벤트 정보
AT_JobAdd 실행된 at 작업, 작업을 마친 시각, 명령을 낸 사용자

감사 이벤트를 고르고 묶는 법과 수집 설정은 Security 안내서의 "Setting Up Auditing"을 봅니다.

RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 특권과 권한 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다. 이 문단은 6.1 문서에만 있습니다.

영어 원문

Auditing Events

If the auditing subsystem is properly configured and is enabled, the at command generates the following audit record or event every time the command is run:

Event Information AT_JobAdd Lists at jobs that were run, the time the task was completed, and the user who issued the command.

For more details about how to properly select and group audit events, and how to configure audit event data collection, see Setting Up Auditing in Security.

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

종료 상태

값 뜻
0 작업을 잘 등록, 삭제, 나열했습니다.
0보다 큼 오류가 났습니다.
영어 원문

This command returns the following exit values:

  • 0 — The at command successfully submitted, removed, or listed a job or jobs.
  • >0 — An error occurred.

예제

  1. 터미널에서 명령을 예약합니다. uuclean이 현재 디렉터리에 있으면 다음 중 하나처럼 입력합니다. 명령 이름을 입력한 뒤 Ctrl-D를 누릅니다.
text
at 5 pm Friday
uuclean
<Ctrl-D>
text
at now next week
uuclean
<Ctrl-D>

uuclean이 $HOME/bin/uuclean에 있으면 다음과 같이 입력합니다.

text
at now + 2 days
$HOME/bin/uuclean
<Ctrl-D>

참고: 명령 이름을 입력 줄의 마지막 항목으로 쓸 때, 명령이 현재 디렉터리에 없으면 전체 경로를 줘야 하며, 인수는 받지 않습니다.

  1. 1월 24일 오후 3시에 uuclean을 실행합니다. 다음 중 하나를 입력합니다.
bash
echo uuclean | at 3:00 pm January 24
echo uuclean | at 3 pm Jan 24
echo uuclean | at 1500 jan 24
  1. 작업이 스스로 다시 예약되게 합니다. 셸 프로시저 안에 다음과 같은 코드를 넣어 at을 부릅니다.
bash
echo "ksh shellfile" | at now tomorrow
  1. 나중에 실행하도록 보낸 작업을 나열합니다.
bash
at -l
  1. 작업을 취소합니다. 작업 ctw.635677200.a를 취소합니다. 작업 번호는 at -l로 봅니다.
bash
at -r ctw.635677200.a
영어 원문
  1. To schedule the command from the terminal, enter a command similar to one of the following: If uuclean is in your current directory, enter:
at 5 pm Friday
uuclean
<Ctrl-D>
at now next week
uuclean
<Ctrl-D>

If uuclean is in $HOME/bin/uuclean, enter:

at now + 2 days
$HOME/bin/uuclean
<Ctrl-D>

Note: When entering a command name as the last item on the command line, a full path name must be given if the command is not in the current directory, and the at command will not accept any arguments.

  1. To run the uuclean command at 3:00 in the afternoon on the 24th of January, enter any one of the following commands:
echo uuclean | at 3:00 pm January 24
echo uuclean | at 3 pm Jan 24
echo uuclean | at 1500 jan 24
  1. To have a job reschedule itself, invoke the at command from within the shell procedure by including code similar to the following within the shell file:
echo "ksh shellfile" | at now tomorrow
  1. To list the jobs you have sent to be run later, enter:
at -l
  1. To cancel a job, enter:
at -r ctw.635677200.a

This cancels job ctw.635677200.a. Use the at -l command to list the job numbers assigned to your jobs.

파일

파일 설명
/var/adm/cron/FIFO crontab이나 at으로 새 작업을 등록할 때 cron 데몬에 메시지를 보내는 이름 있는 파이프입니다.
/usr/bin/at at 명령이 들어 있습니다.
/var/adm/cron cron의 주 디렉터리입니다.
/var/adm/cron/at.allow 허용한 사용자 목록입니다.
/var/adm/cron/at.deny 거부한 사용자 목록입니다.
/var/spool/cron/atjobs at의 스풀 영역 디렉터리입니다.

관련 명령어: batch, atrm, bsh, csh, cron

영어 원문
  • /var/adm/cron/FIFO — A named pipe that sends messages to the cron daemon when new jobs are submitted with the crontab or at commands.
  • /usr/bin/at — Contains the at command.
  • /var/adm/cron — Contains the main cron directory.
  • /var/adm/cron/at.allow — Specifies the list of allowed users.
  • /var/adm/cron/at.deny — Specifies the list of denied users.
  • /var/spool/cron/atjobs — Contains the spool area directory for at.

Related reference:

  • batch Command

Related information:

  • bsh command
  • csh command
  • cron command
  • atrm command

리눅스(GNU)와 다른 점

항목 AIX 5.3·6.1 리눅스 at
목록·삭제 at -l, at -r 작업 atq(at -l), atrm(at -r, at -d)
셸 고르기 -k(ksh), -c(csh), -s(bsh) SHELL 환경 변수의 셸
작업 번호 ctw.635677200.a 같은 이름 정수
허용 파일 /var/adm/cron/at.allow, at.deny /etc/at.allow, /etc/at.deny
데몬 cron 데몬이 처리 atd 데몬