'at' executes a command once on a particular day, at a particular time. at will add a particular command to be executed.
Examples:
You then type the commands you want executed then press the end-of-file character (normally CTRL-D ). Also try:
This will run at at the current time + the hours/mins/seconds you specify (use at now + 1 hour to have command(s) run in 1 hour from now...)
You can also use the -f option to have at execute a particular file (a shell script).
at -f shell_script now + 1 hour
|
This would run the shell script 1 hour from now.
crontab crontab is used to edit, read and remove the files which the cron daemon reads.
Options for crontab (use crontab -option(s)):
When using crontab -e you have a number of fields (6) what they mean is listed below:
There are also a number of shortcut methods for common tasks, including:
-
@reboot --- run command at reboot
-
@yearly --- same as 0 0 1 1 *
-
@annually --- same as @yearly
-
@monthly --- same as 0 0 1 * *
-
@weekly --- same as 0 0 * * 0
-
@daily --- same as 0 0 * * *
-
@midnight --- same as @daily
-
@hourly --- same as 0 * * * *
Note that * (asterisk) is used to mean anything (similar to the wildcard). For example if you leave the day part (the 5th place) with an asterisk it would mean everyday.
Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12".
Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies skips of the number's value through the range. For example, ``0-23/2'' can be used in the
hours field to specify command execution every other hour (the alternative in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to say
``every two hours'', just use ``*/2''.
When writing a crontab entry you simply type in six fields separated by spaces, the first five are those listed in the table (using numbers or letters and numbers as appropriate), the 6th field is
the command to be executed and any options, cron will read everything up until the newline.
Example:
5 4 * * sun echo "run at 5 after 4 every sunday"
|
This would run the echo command with the string shown at 4:05 every Sunday.