Special File Types   «Prev 

Use Unix at command like cron

You can use the at command in much the same way as cron. What is the difference? Whereas you use cron to run a program over time repeatedly, you can use the at command to run a command at one specified time. The syntax for at is
at options time date

Options for the at command include:
  1. -f, which allows at to execute commands inside a text file
  2. -m, which sends an email to the person who scheduled the at command upon completion of the task

You should use a specific time format. For example, if you want to schedule a series of commands contained in the file trail.sh to run at 6:30 p.m., you would enter
at -f trial.sh 0630pm

To obtain a listing of scheduled events, use the atq command. This command also has several options:
  1. -c will sort the list according to when the list was generated by the at command.
  2. -n will display a numbered list of at events.
If you want to remove scheduled at entries, use the atrm command and provide the proper number for the at entry. If you do not know the number, you can first issue the atq command. You will then receive a message such as
1 1999-06-14 18:30 a

This message informs you that you have one command prepared to execute. To remove it, enter
atrm 1

If you have multiple commands in line to execute, enter the number of the command you want to delete from the list. For example, atrm 1 deletes the first command,
atrm 7
deletes the seventh command, and so forth.