CMD | AT

|^^|

source: http://www.brunolinux.com/02-The_Terminal/The_at_Command.html

THE "AT" COMMAND

Today we have something simple that actually is a bit complicated to explain . . . . . it is about the command "at". This command "at" lets you execute a command or script at a later time, you can set the time in many different ways and even have the result mailed to you after the command has been executed.

Now, using "at" is not only just typing the command and hitting the enter-key . . . there is a little more to it, so let me give an example. In the example we want to have the command "play /usr/share/sounds/KDE_Startup.wav" executed at 12:49 . . . . have a look what I see in the terminal:

|^^|

source: http://serverfault.com/questions/204265/how-to-configure-cron-job-to-run-every-2-days-at-11pm

CRONTAB COMMAND

crontab -e

0 23 */2 * * insert_your_script_here.sh

crontab -e -u root

This will put you in VI editing root's crontab entry. Then as ewwhite says, enter:

0 23 */2 * * insert_your_script_here.sh

and then [^ESC] ZZ to save the changes.

This is a good first attempt, but this is not quite every alternate day, as it will run on the 30th of the month and then next run on the 2nd of the month. If you really do need it to be every 2nd day, then run the script EVERY night.

0 23 * * * insert_your_script_here.sh

and in the start of the script use

#/bin/sh if -f /tmp/altday.txt rm /tmp/altday.txt exit fi touch /tmp/altday.txt

This uses a text file to force the script to exit every alternate invocation.

QUOTE

$ at 12:49 -m

warning: commands will be executed using (in order) a) $SHELL b) login shell c) /bin/sh

at> play /usr/share/sounds/KDE_Startup.wav

at> <EOT>

job 7 at 2006-05-01 12:49

- On the 1st line you see the command "at 12:49 -m", meaning execute at 12:49 and the "-m" means mail me when the job is finished.

- On the 2nd line it will print some info about the at command and jump to line 3

- On the 3rd line you will see the "at>" prompt, at the "at>" prompt you type the command you want to have executed and you hit the enter-key again.

- On the 4th line you get the "at>" prompt appearing again, this time you pressCtrl+D and it will print <EOT>

- The 5th it will then automatically print the job number and the time the given command will be executed.

APPLICATION USAGE

The format of the at command line shown here is guaranteed only for the

POSIX locale. Other cultures may be supported with substantially dif‐

ferent interfaces, although implementations are encouraged to provide

comparable levels of functionality.

Since the commands run in a separate shell invocation, running in a

separate process group with no controlling terminal, open file descrip‐

tors, traps, and priority inherited from the invoking environment are

lost.

Some implementations do not allow substitution of different shells

using SHELL. System V systems, for example, have used the login shell

value for the user in /etc/passwd. To select reliably another command

interpreter, the user must include it as part of the script, such as:

$ at 1800

myshell myscript

EOT

job ... at ...

$

EXAMPLES

1. This sequence can be used at a terminal:

at −m 0730 tomorrow

sort < file >outfile

EOT

2. This sequence, which demonstrates redirecting standard error to a

pipe, is useful in a command procedure (the sequence of output re‐

direction specifications is significant):

at now + 1 hour <<!

diff file1 file2 2>&1 >outfile | mailx mygroup

!

3. To have a job reschedule itself, at can be invoked from within the

at-job. For example, this daily processing script named my.daily

runs every day (although crontab is a more appropriate vehicle for

such work):

# my.daily runs every day

daily processing

at now tomorrow < my.daily

4. The spacing of the three portions of the POSIX locale timespec is

quite flexible as long as there are no ambiguities. Examples of

various times and operand presentation include:

at 0815am Jan 24

at 8 :15amjan24

at now "+ 1day"

at 5 pm FRIday

at '17

utc+

30minutes'

eof