COHERENT manpages

This page displays the COHERENT manpage for at [Execute commands at given time].

List of available manpages
Index


at -- Command

Execute commands at given time
at [ -v ] [ -c command ] time [ [ day ] week ] [ file ]
at [ -v ] [ -c command ] time month day [ file ]

at executes commands at a given time in the future.

If the  -c option is  used, at executes  the following command.  If file is
named, at  reads the commands from  it.  If neither is  given, at reads the
standard input for commands.

If time is a one-digit or  two-digit number, at interprets it as specifying
an hour.  If  time is a three-digit or four-digit  number, at interprets it
as specifying an  hour and minutes.  If time is  followed by a, p, n, or m,
at assumes  AM, PM, noon, or midnight,  respectively; otherwise, it assumes
that time indicates a 24-hour clock.  Note that you should not type a colon
`:' in the time string.

For example, the command

    at -c "time | msg henry" 1450

set the time  command to be executed at 2:50  PM, and pipe time's output to
the msg  command, which will  pass it to  the terminal of  user henry.  The
argument to the -c option had  to be enclosed in quotation marks because it
contains spaces and special characters; if this were not done, at would not
be able  to tell when  the argument ended,  and so would  generate an error
message.  If you wish to pass  information to a user's terminal with the at
command, you must tell at to whom to send the information.  The command

    at 250p commandfile

sets the  file commandfile to be  read and executed at 2:50  PM.  It is not
necessary to use the file's full path name.  Also, if the suffix p were not
appended to the time, the file would be set to be read at 2:50 AM.

The time set in at's command line is not the exact time that the command is
executed.   Rather,  the  daemon  cron  periodically executes  the  command
/usr/lib/atrun to  see if any  commands have been scheduled  commands to be
executed  at or  before the  present time.  The  frequency with  which cron
executes atrun  determines the ``granularity''  of at execution  times.  To
change when  cron executes atrun,  edit file /usr/spool/cron/crontabs/root.
For example, the entry

    0,5,10,15,20,25,30,35,40,45,50,55 * * * *   /usr/lib/atrun

sets  /usr/lib/atrun  to be  executed  every five  minutes.   Thus, the  at
command that is  set, for example, to 2:53 PM  will actually be executed at
2:55  PM.  atrun  executes specified  commands when  it discovers  that the
given time is past; therefore, at  commands are executed even if the system
is down at the specified time or if the system's time is changed.

The  at command  has two  forms, as  shown above.  In  the first  form, the
option day names  a day of the week (lower  case, spelled out).  If week is
specified, at  interprets the given time  and day as meaning  that time and
day the following week.  For example, the command

    at -c "time | msg henry" 1450 friday week

executes time and sends its output to henry's terminal one week from Friday
at 2:50 PM.

In the second  form given above, month specifies a  month name (lower case,
spelled out) and the number day specifies a day of the month.  For example,
the command

    at 1450 july 4 commandfile

set the file commandfile to be read at 2:50 PM on July 4.

If  the -v flag  is given,  at prints  the time when  the commands  will be
executed, giving  you enough information  to plan for the  execution of the
command.  For  example, if it is  now August 13, 1990, at  2:30 PM, and you
type the command

    at -v -c "/usr/games/fortune | msg henry" 1435

at will reply:

    Tue Aug 13 14:35:00

indicating  that  the  command will  be  executed  five  minutes from  now.
However, if you type

    at -v -c "/usr/games/fortune | msg henry" 1435 august 10

at will reply

    Sun Aug 10 14:35:00 1991

which indicates  that on Sunday,  August 10 of  next year, at  2:35 PM, the
COHERENT system will print a fortune onto your terminal.

Should you create such a long-distance at file by accident, you can correct
the error  by simply deleting the  file that encodes it  from the directory
/usr/spool/at.  The  file will be  named after the  time that it  is set to
execute, plus  a unique two-character suffix, should  more than one command
be scheduled to run at the  same time.  For example, the file for the above
command would be named 9108101435.aa.

Finally, note that the current working directory, exported shell variables,
file  creation mask,  user id,  and group  id are  restored when  the given
command is executed.

Example

The following example  invokes the command wall at 11  P.M. to confirm that
the at command is working properly:

    at -c "echo 'testing to see if cron is working' | /etc/wall" 2300

Files

/bin/pwd -- To find current directory
/usr/lib/atrun -- Execute scheduled commands
/usr/spool/at -- Scheduled activity directory
/usr/spool/at/ yymmddhhmm.xx -- Commands scheduled at given time

See Also

at,
commands,
cron