Skip to Content
Running Linux, 5th Edition
book

Running Linux, 5th Edition

by Matthias Kalle Dalheimer, Matt Welsh
December 2005
Beginner
974 pages
31h 50m
English
O'Reilly Media, Inc.
Content preview from Running Linux, 5th Edition

Executing Jobs Once

With cron, you can schedule recurring jobs, as we have seen in the previous section. But what if you want to run a certain command just once or a limited number of times, but still at times when it is inconvenient to type in the command interactively? Of course, you could always add the command to the crontab and then remove it later, or pick a date selection that only applies very rarely. But there is also a tool that is made for this job, the at command.

at reads commands to be executed from a file or from standard input. You can specify the time in a number of ways, including natural-language specifications such as noon, midnight, or, interestingly, teatime (which, much to the dismay of British users, maps to 4 p.m.).

For at to work, the at daemon, atd, needs to run. How it is started depends on your distribution: rcatd start and /etc/init.d/atd start are good tries. In a pinch, you should also be able to just run /usr/sbin/atd as root.

As an example, let's say that you want to download a large file from the Internet at midnight when your ISP is cheaper or when you expect the lines to be less congested so that the probability of success is higher. Let's further assume that you need to run a command connectinet for setting up your (dial-up) Internet connection, and disconnectinet for shutting it down. For the actual download in this example, we use the wget command:

    tigger$ at midnight warning: commands will be executed using /bin/sh at> connectinet at> wget ftp://overloadedserver.lotsastuff.com/pub/largefiles/reallylargefile.bz2 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Running Linux, Third Edition

Running Linux, Third Edition

Matthias Kalle Dalheimer, Lar Kaufman, Matt Welsh
Linux in a Nutshell, 6th Edition

Linux in a Nutshell, 6th Edition

Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins
Linux in Action

Linux in Action

David Clinton
Linux Under the Hood

Linux Under the Hood

Sander van Vugt

Publisher Resources

ISBN: 0596007604Errata Page