JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
System Administration Guide: Advanced Administration
search filter icon
search icon

Document Information

Preface

1.  Managing Terminals and Modems (Overview)

2.  Setting Up Terminals and Modems (Tasks)

3.  Managing Serial Ports With the Service Access Facility (Tasks)

4.  Managing System Resources (Overview)

5.  Displaying and Changing System Information (Tasks)

6.  Managing Disk Use (Tasks)

7.  Managing UFS Quotas (Tasks)

8.  Scheduling System Tasks (Tasks)

Creating and Editing crontab Files (Task Map)

Ways to Automatically Execute System Tasks

For Scheduling Repetitive Jobs: crontab

For Scheduling a Single Job: at

Scheduling a Repetitive System Task (cron)

Inside a crontab File

How the cron Daemon Handles Scheduling

Syntax of crontab File Entries

Creating and Editing crontab Files

How to Create or Edit a crontab File

How to Verify That a crontab File Exists

Displaying crontab Files

How to Display a crontab File

Removing crontab Files

How to Remove a crontab File

Controlling Access to the crontab Command

How to Deny crontab Command Access

How to Limit crontab Command Access to Specified Users

How to Verify Limited crontab Command Access

Using the at Command (Task Map)

Scheduling a Single System Task (at)

Description of the at Command

Controlling Access to the at Command

How to Create an at Job

How to Display the at Queue

How to Verify an at Job

How to Display at Jobs

How to Remove at Jobs

How to Deny Access to the at Command

How to Verify That at Command Access Is Denied

9.  Managing System Accounting (Tasks)

10.  System Accounting (Reference)

11.  Managing System Performance (Overview)

12.  Managing System Processes (Tasks)

13.  Monitoring System Performance (Tasks)

14.  Troubleshooting Software Problems (Overview)

15.  Managing System Messages

16.  Managing Core Files (Tasks)

17.  Managing System Crash Information (Tasks)

18.  Troubleshooting Miscellaneous Software Problems (Tasks)

19.  Troubleshooting File Access Problems (Tasks)

20.  Resolving UFS File System Inconsistencies (Tasks)

21.  Troubleshooting Software Package Problems (Tasks)

Index

Scheduling a Repetitive System Task (cron)

The following sections describe how to create, edit, display, and remove crontab files, as well as how to control access to them.

Inside a crontab File

The cron daemon schedules system tasks according to commands found within each crontab file. A crontab file consists of commands, one command per line, that will be executed at regular intervals. The beginning of each line contains date and time information that tells the cron daemon when to execute the command.

For example, a crontab file named root is supplied during SunOS software installation. The file's contents include these command lines:

10 3 * * * /usr/sbin/logadm (1)
15 3 * * 0 /usr/lib/fs/nfs/nfsfind (2)
1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1 (3)
30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean (4)

The following describes the output for each of these command lines:

For more information about the syntax of lines within a crontab file, see Syntax of crontab File Entries.

The crontab files are stored in the /var/spool/cron/crontabs directory. Several crontab files besides root are provided during the Oracle Solaris software installation. See the following table.

Table 8-2 Default crontab Files

crontab File
Function
adm
Accounting
lp
Printing
root
General system functions and file system cleanup
sys
Performance data collection
uucp
General uucp cleanup

Besides the default crontab files, users can create crontab files to schedule their own system tasks. Other crontab files are named after the user accounts in which they are created, such as bob, mary, smith, or jones.

To access crontab files that belong to root or other users, superuser privileges are required.

Procedures explaining how to create, edit, display, and remove crontab files are described in subsequent sections.

How the cron Daemon Handles Scheduling

The cron daemon manages the automatic scheduling of crontab commands. The role of the cron daemon is to check the /var/spool/cron/crontab directory for the presence of crontab files.

The cron daemon performs the following tasks at startup:

In much the same way, the cron daemon controls the scheduling of at files. These files are stored in the /var/spool/cron/atjobs directory. The cron daemon also listens for notifications from the crontab commands regarding submitted at jobs.

Syntax of crontab File Entries

A crontab file consists of commands, one command per line, that execute automatically at the time specified by the first five fields of each command line. These five fields, described in the following table, are separated by spaces.

Table 8-3 Acceptable Values for crontab Time Fields

Time Field
Values
Minute
0-59
Hour
0-23
Day of month
1-31
Month
1-12
Day of week
0-6 (0 = Sunday)

Follow these guidelines for using special characters in crontab time fields:

For example, the following crontab command entry displays a reminder in the user's console window at 4 p.m. on the first and fifteenth days of every month.

0 16 1,15 * * echo Timesheets Due > /dev/console

Each command within a crontab file must consist of one line, even if that line is very long. The crontab file does not recognize extra carriage returns. For more detailed information about crontab entries and command options, refer to the crontab(1) man page.