x
Loading
 Loading
Hello, Guest | Login | Register

Running Jobs Unattended

Linux systems have several ways to run jobs unattended at some later time — either once or many times. Scheduling jobs in the future is handy for system maintenance, for sending yourself reminders, and for making more practical and efficient use of your CPU by running jobs when users are away.

Linux systems have several ways to run jobs unattended at some later time — either once or many times. Scheduling jobs in the future is handy for system maintenance, for sending yourself reminders, and for making more practical and efficient use of your CPU by running jobs when users are away.

As usual though, there are gotchas: if you want to run multiple commands or run commands that need a particular setup (including environment variables, a tty, or a certain current directory), or want to avoid system overload, you need to know a few tricks. This month, let’s dig into job scheduling systems, discuss the potential problems, and find some answers.

Catching some Zs

An easy way to delay execution is with the sleep command. sleep simply waits for some number of seconds (for instance, sleep 60 waits sixty seconds) and then exits.

For example, let’s say you’re going to lunch and you have three big files named a, b, and c to print on your office laser printer. However, you don’t want to tie up the printer constantly. Here’s how you could run one lpr print job, wait ten minutes, run the next job, and so on:

 % lpr a; sleep 600; lpr b; sleep 600; lpr c 

The ; (semicolon) is the shell’s command separator. With it, you can string several commands together at a single prompt. Commands run in the order you type them, and you won’t get…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. KDE 4.4: Does It Work Yet?
  2. Writing Custom Nagios Plugins with Python
  3. Power Up Linux GUI Apps
  4. Tweeting from the Command Line with Twyt
  5. When Memory Serves You: Using ramfs and tmpfs
Follow Linux Magazine
Rackspace