Scheduling Reports from the Command Line for UNIX or Linux

You can schedule a report from the command line for processing on a future date, daily, or even a recurring day of the week. This task can be accomplished by using the operating system utilities called at, batch, and cron. The batch and at utilities are used to schedule single occurrence jobs; cron can be used to schedule recurring jobs. Use the at command or the batch command to schedule a job at a later time. The command line structure of these commands is identical, but you use them differently.

The batch command is intended to run a job immediately in the background, providing that the system load is low enough to handle the request. If the system load is not low enough, the job is held until system activity is low enough to handle the new request load.

The at command also runs jobs in the background, but enables you to schedule the job to run at a future time. You can use this utility to run the batch job during off-peak hours.

The command format for the batch command is as follows:

batch command

The command format for the at command is as follows:

at -t CCYYMMDDHHMMSS command

The -t switch is used to schedule the time. This table describes the CCYYMMDDHHMMSS variable:

Segment

Description

CC

Century (first two digits of the year).

YY

Year (last two digits of the year).

MM

Two-digit value of the month (such as 02 for February).

DD

The day of the month (01 - 31).

HH

The hour to start the job (00 - 23).

MM

The minute to start the job (00 - 59).

SS

The second to start the job (00 - 59).

command

The command to run at the specified time. To schedule a report, use the runube command.

You can use the cron UNIX utility to run jobs at a scheduled time. You can specify variable times, such as once a year or once every hour. The operation of this utility is controlled by a table of events based upon each user.

Enter this command to modify the cron schedule and edit the cron table for the current user:

crontab -e

The format of the cron table is as follows:

mm HH DD MM W command

This table describes the variables for this command:

Segment

Description

mm

The minute to run the job (00 - 59, or * for any minute).

HH

The hour to run the job (00 - 23, or * for any hour).

DD

The day of the month to run the job (0 - 31, or * for any day).

MM

The month to run the job (1 - 12, or * for any month).

W

The day of the week to run the job (0 - 6, with 0 being Sunday).

command

The command to run at the specified time.

After exiting the editor, the operating system should respond with a message stating that the crontab has been modified.