Saturday, March 1

Crontab

crontab -a filenameInstall filename as your crontab file. On many systems, this command is executed simply as crontab filename (i.e., without the -a  option).
crontab -eEdit your crontab file, or create one if it doesn't already exist.
crontab -lDisplay your crontab file.
crontab -rRemove your crontab file.
crontab -vDisplay the last time you edited your crontab file. (This option is available on only a few systems.)
crontab -u userUsed in conjunction with other options, this option allows you to modify or view the crontab file of user. When available, only administrators can use this option.
FieldValueDescription
minute0-59The exact minute that the command sequence executes
hour0-23The hour of the day that the command sequence executes
day1-31The day of the month that the command sequence executes
month1-12The month of the year that the command sequence executes
weekday0-6The day of the week that the command sequence executes (Sunday = 0, Monday = 1, Tuesday = 2, and so forth)
commandSpecialThe complete sequence of commands to execute. The command string must conform to Bourne shell syntax. Commands, executables (such as scripts), or combinations are acceptable.
# Example 1:  0,30 8-17 * * 1-5 cmd
Show/Hide Answer (+/-)
Run cmd on the half-hour from 8:00 AM to 5:30 PM, Monday thru Friday
# Example 2:  0 12 1,15 * 5 cmd
Show/Hide Answer (+/-)
Run cmd at noon each Friday AND the first and fifteenth of every month
# Example 3:  17 3 * * 1 cmd
Show/Hide Answer (+/-)
Run cmd at 3:17 AM Monday (a backup program perhaps)
# Example 4:
# This command sends a "popup" message to the user's screen,
# at 3:00 PM Fridays, if they are logged in:
0 15 * * 5 echo "Time for staff meeting" | write $LOGNAME >/dev/null 2">"&1

# Example 5:
# This command sends a multi-line "popup" message to the user's screen,
# at 3:00 PM Fridays, if they are logged in:
0 15 * * 5 write $LOGNAME '>'/dev/null 2'>'&1 %Time for the%staff meeting.

No comments:

Post a Comment