Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
  Previous   Contents   Next 
   
 
Chapter 18

Scheduling System Tasks (Tasks)

This chapter describes how to schedule routine or single (one-time) systems tasks by using the crontab and at commands. This chapter also explains how to control access to these commands by using cron.deny, cron.allow, and at.deny files.

This is a list of the step-by-step instructions in this chapter.

Ways to Automatically Execute System Tasks

You can set up many system tasks to execute automatically. Some of these tasks should occur at regular intervals. Other tasks need to run only once, perhaps during off hours such as evenings or weekends.

This section contains overview information about two commands, crontab and at, which enable you to schedule routine tasks to execute automatically. The crontab schedules repetitive commands. The at command schedules tasks that execute once.

The following table summarizes crontab and at commands, as well as the files that enable you to control access to these commands.

Table 18-1 Command Summary: Scheduling System Tasks

Command

What It Schedules

Location of Files

Files That Control Access

crontab

Multiple system tasks at regular intervals

/var/spool/cron/crontabs

/etc/cron.d/cron.allow and /etc/cron.d/cron.deny

at

A single system task

/var/spool/cron/atjobs

/etc/cron.d/at.deny

You can also use the Solaris Management Console's Scheduled Jobs tool to schedule routine tasks. For information on using and starting the Solaris Management Console, see "Working With the Management Console (Tasks)" in System Administration Guide: Basic Administration.

For Scheduling Repetitive Jobs: crontab

You can schedule routine system administration tasks to execute daily, weekly, or monthly by using the crontab command.

Daily crontab system administration tasks might include:

  • Removing files more than a few days old from temporary directories

  • Executing accounting summary commands

  • Taking snapshots of the system by using the df and ps commands

  • Performing daily security monitoring

  • Running system backups

Weekly crontab system administration tasks might include:

  • Rebuilding the catman database for use by the man -k command

  • Running the fsck -n command to list any disk problems

Monthly crontab system administration tasks might include:

  • Listing files not used during a specific month

  • Producing monthly accounting reports

Additionally, users can schedule crontab commands to execute other routine system tasks, such as sending reminders and removing backup files.

For step-by-step instructions on scheduling crontab jobs, see "How to Create or Edit a crontab File".

For Scheduling a Single Job: at

The at command allows you to schedule a job for execution at a later time. The job can consist of a single command or a script.

Similar to crontab, the at command allows you to schedule the automatic execution of routine tasks. However, unlike crontab files, at files execute their tasks once, and then are removed from their directory. Therefore, at is most useful for running simple commands or scripts that direct output into separate files for later examination.

Submitting an at job involves entering a command and following the at command syntax to specify options to schedule the time your job will be executed. For more information about submitting at jobs, see "Description of the at Command".

The at command stores the command or script you entered, along with a copy of your current environment variable in the /var/spool/cron/atjobs directory. Your at job file name is given a long number that specifies its location in the at queue, followed by the .a extension, such as 793962000.a.

The cron daemon periodically executes the atrun program, usually at 15-minute intervals. Then the atrun program executes at jobs at their scheduled times. After the cron daemon executes your at job, the at job's file is removed from the atjobs directory.

For step-by-step instructions on scheduling at jobs, see "How to Create an at Job".

 
 
 
  Previous   Contents   Next