HP NonStop G-Series User Manual

Page 146

Advertising
background image

month

is the month of the year (1 through 12) of execution.

weekday

is the day of the week (0 through 6 for Sunday through Saturday) of execution.

command

is the command to be executed.

In addition to a number in the preceding ranges, each field in a crontab entry can also be:

An asterisk (*), indicating all legal values

Two numbers separated by a hyphen, indicating a range of values

A list of numbers separated by commas, indicating all values in the list

Each entry in a crontab file requests execution of a single OSS command

For example, the following entry writes to file datefile at 10:00 a.m. on February 5. Note that,
since the day the command is to execute is selected by the third (“day”) field, the fifth (“weekday”)
field is specified as *:

0 10 5 2 * echo The date is ‘date’ > /datefile

The following entry executes the cal command at 6:30 a.m. every Monday, Wednesday, and
Friday:

30 6 * * 1,3,5 cal > /calfile

The following entry writes to file timefile every 15 minutes:

0,15,30,45 * * * * echo The time is ‘date’ > /timefile

The following entry writes a message at 4:00 p.m. to all users logged in beginning Friday December
10 through December 31. The string enclosed by % (percent) signs defines the standard input file
to the wall command.

0 16 10-31 12 5 wall %Happy Holidays%

To submit a crontab file to cron, enter the command

crontab file

where file is your crontab configuration file. For example:

$ crontab mycommands

submits file mycommands to cron.

To make changes to an existing crontab file, use the command

$ crontab -e

This command opens your current crontab file in the crontab file directory using the vi editor,
allowing you to edit the file. Other useful crontab command options are:

Lists the contents of your crontab file.

$ crontab -l

Removes your crontab file from the crontab file directory.

$ crontab -r

For more information about cron and crontab, see the crontab(1) reference page either
online or in the Open System Services Shell and Utilities Reference Manual.

146

Managing Processes

Advertising
This manual is related to the following products: