The UNIX at Utility

The at−jobs are submitted to the a queue for execution. There are two additional queues reserved for special jobs: the b queue is reserved for batch−jobs, and the c queue is reserved for cron−jobs. New queues can be created, but they must be named by lower−case letters except the already−taken letters a, b, and c. This can be done by using the −q option of the at utility. The queue characteristics are described in the etclibcronqueuedefs file or the etc cron.dqueuedefs file. Each queue is identified by a corresponding entry of the form: q.[njobj][nicen][nwaitw] where q The name of the queue terminated by the . njob The maximum number of jobs that can run simultaneously terminated by the letter j nice The nice value to give to all jobs in the queue terminated by the letter n nwait The number of seconds to wait before rescheduling a job that was deferred because more than njob jobs were already running terminated by the letter w By default, only the reserved queues a and b are described. Here is the queuedefs file on Solaris 2.6: cat etccron.dqueuedefs a.4j1n b.2j2n90w Please note that the schedule batch−jobs are running with lower priority, the nice value is 2.

13.3.1 The UNIX at Utility

The at utility reads commands from the standard input and groups them together into an at−job to be executed at a later, specified time. The format of the at utility is: at [option] [operand] command 1 command 2 ..... [Cntrl−D] where the main options are: −c, −k, or −s Specifies the C shell, Korn shell, or Bourne shell to be used to execute an at−job. −f file Specifies the path of the file to be used as the source of the at−job, instead of the standard input. −l Reports specified at−jobs, if any, or all at−jobs scheduled for the invoking user. −m Sends an e−mail to the invoking user upon the completion of the at−job. Standard output and error of the at−job are also e−mailed unless they are redirected elsewhere. −q queuename Specifies the queue to schedule a job for submission. Queues are identified with lowercase letters, but the reserved queues are: a for at−jobs, b for batch jobs, and c for cron−jobs. 315 −t timespec Submits a job to be run at the time specified by the timespec operand. The operands are: at−job−id Identifies a scheduled at−job timespec Submit the at−job to be run at the date and time specified. All timespec operands are concatenated and then interpreted. The time can be specified as: hours One− or two−digit number hours:minutes Four−digit number specified as AM or PM, or default as a 24−hour clock time midnight Indicates the time 12:00 AM 00:00 noon Indicates the time 12:00 PM 12:00 now Indicates the current day and time, i.e., an immediate run The date can be specified as: date In the form Mar 27, 2001 today Indicates the current day tomorrow Indicates the day following the current day increment The optional increment is a number preceded by the +sign and suffixed by one of the following: minutes, hours, days, weeks, month, or years. not specified Today is assumed. A few examples follow: To write a sorted contents of the file homebjlData.raw into the file homebjlData.sorted tomorrow at 10:30 am, and to send an e−mail upon completion: at −m 2030 tomorrow cd homebjl sort Data.raw Data.sorted [Ctrl−D] • Anat−job can be invoked within the same at−job to self−reschedule a job, although a crontab entry is more appropriate for such work. This daily data processing script named Data.daily will run every day: binksh This is the script usrlocalbinData.daily. It provides a needed daily data processing. Once it is started, the script runs every day at now tomorrow usrlocalbinData.daily A sequence of commands for data processing ..... ..... The end of the script Once the script is invoked, it schedules its immediate execution, as well as execution the next day. The next day it is repeated, and so on… • The Here Document is very convenient for scheduling an at−job in a ksh script: binksh • 316

13.4 Batch Processing