System Administration Guide: Advanced Administration

ProcedureHow to Create an at Job

  1. Start the at utility, specifying the time you want your job executed.


    $ at [-m] time [date] 
    -m

    Sends you email after the job is completed.

    time

    Specifies the hour that you want to schedule the job. Add am or pm if you do not specify the hours according to the 24-hour clock. Acceptable keywords are midnight, noon, and now. Minutes are optional.

    date

    Specifies the first three or more letters of a month, a day of the week, or the keywords today or tomorrow.

  2. At the at prompt, type the commands or scripts that you want to execute, one per line.

    You may type more than one command by pressing Return at the end of each line.

  3. Exit the at utility and save the at job by pressing Control-D.

    Your at job is assigned a queue number, which is also the job's file name. This number is displayed when you exit the at utility.


Example 8–7 Creating an at Job

The following example shows the at job that user jones created to remove her backup files at 7:30 p.m. She used the -m option so that she would receive an email message after her job completed.


$ at -m 1930
at> rm /home/jones/*.backup
at> Press Control-D
job 897355800.a at Thu Jul  12 19:30:00 2004

She received a email message which confirmed the execution of her at job.


Your “at” job “rm /home/jones/*.backup”
completed.

The following example shows how jones scheduled a large at job for 4:00 a.m. Saturday morning. The job output was directed to a file named big.file.


$ at 4 am Saturday
at> sort -r /usr/dict/words > /export/home/jones/big.file