[Chapter 40] Delayed Execution
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:50:32Z

#

| Chapter 40 |

# 40. Delayed Execution

Contents:
Off-Peak Job Submission
Waiting a Little While: sleep
The at Command
Choosing the Shell Run (We Hope) by at
Avoiding Other at and cron Jobs
System V.4 Batch Queues
Making Your at Jobs Quiet
Automatically Restarting at Jobs
Checking and Removing Jobs
nextday, nextweekday: Tomorrow or Next Weekday
Send Yourself Reminder Mail
Periodic Program Execution: The cron Facility
Adding crontab Entries
Including Standard Input Within a cron Entry
crontab Script Makes crontab Editing Easier/Safer

## 40.1 Off-Peak Job Submission

Now that time sharing and interactive programming have become universal, many UNIX users have forgotten one of the best ways to get the most out of the system: running jobs at nights or on the weekend. Most people tend to work from 9 to 5, which is roughly one-third of the day. (Though many programmers do keep later hours!) If you can make use of the other hours (night and weekends), you can almost quadruple your system's throughput. Running jobs at night is less fun than running them interactively, but it is a lot less expensive than three new machines. If you can use off-peak hours, you will get a lot more work from your hardware.

There are a few mechanisms to take advantage of off-peak hours:

- The at command (40.3) lets you submit jobs for execution at an arbitrary later date; it is standard on almost all UNIX systems.

- The batch command (40.6), which is available in System V.4 and SunOS 4.1, provides a simple (and simplistic) batch queueing system. Some more fully featured batch systems are available for other UNIX systems.

- Although it serves an entirely different purpose, you should also be aware of the crontab (40.12) facility, which provides a way to schedule jobs for periodic execution on a regular basis.

- Finally, don't forget sleep (40.2), which can be helpful if you want to delay or space out execution just a little bit.

- ML

39.12 What Makes Your Computer Slow? How Do You Fix It? |  | 40.2 Waiting a Little While: sleep