Download Linux All-in-One Desk Reference for Dummies (ISBN - 0764579363) PDF

TitleLinux All-in-One Desk Reference for Dummies (ISBN - 0764579363)
TagsFor Dummies
LanguageEnglish
File Size12.0 MB
Total Pages817
Table of Contents
                            Preliminaries
Book I: Linux Basics
Book II: Linux Desktops
Book III: Networking
Book IV: Internet
Book V: Administration
Book VI: Security
Book VII: Internet Servers
Book VIII: Programming
Appendices
Index
                        
Document Text Contents
Page 1

by Naba Barkakati

Linux®
A l l - i n - O n e D E S K R E F E R E N C E

FOR

DUMmIES



C1.jpg

Page 408

Scheduling Jobs in Linux382

To use at to schedule a one-time job for execution at a later time, follow
these steps:

1. Run the at command with the date or time when you want your com-
mands executed.

When you press Enter, the at> prompt appears, as follows:

at 21:30
at>

This method is the simplest way to indicate the time when you want to
execute one or more commands — simply specify the time in a 24-hour
format. In this case, you want to execute the commands at 9:30 p.m.
tonight (or tomorrow, if it’s already past 9:30 p.m.). You can, however,
specify the execution time in many different ways. (See Table 1-12 for
examples.)

2. At the at> prompt, type the commands you want to execute as if typing
at the shell prompt; after each command, press Enter and continue
with the next command. When you finish entering the commands you
want to execute, press Ctrl+D to indicate the end.

Here is an example showing how to execute the ps command at a future
time:

at> ps
at> <EOT>
job 1 at 2004-12-28 21:30

After you press Ctrl+D, the at command responds with a job number
and the date and time when the job will execute.

Table 1-12 Formats for the Time of Execution with the at Command
Command When the Job Will Run

at now Immediately
at now + 15 minutes 15 minutes from the current time
at now + 4 hours 4 hours from the current time
at now + 7 days 7 days from the current time
at noon At noontime today (or tomorrow, if already past noon)
at now next hour Exactly 60 minutes from now
at now next day At the same time tomorrow
at 17:00 tomorrow At 5:00 p.m. tomorrow
at 4:45pm At 4:45 p.m. today (or tomorrow, if it’s already past

4:45 p.m.)

at 3:00 Dec 28, 2004 At 3:00 a.m. on December 28, 2004

Page 409

Book V
Chapter 1

Learning B
asic

S
ystem

A
dm

inistration
Scheduling Jobs in Linux 383

After you enter one or more jobs, you can view the current list of scheduled
jobs with the atq command:

atq

The output looks similar to the following:

4 2004-12-28 03:00 a root
5 2004-10-26 21:57 a root
6 2004-10-26 16:45 a root

The first field on each line shows the job number — the same number that
the at command displays when you submit the job. The next field shows the
year, month, day, and time of execution. The last field shows the jobs pend-
ing in the queue named a.

If you want to cancel a job, use the atrm command to remove that job from
the queue. When removing a job with the atrm command, refer to the job by
its number, as follows:

atrm 4

This command deletes job 4 scheduled for 3:00 a.m. December 28, 2004.

When a job executes, the output is mailed to you. Type mail at a terminal
window to read your mail and to view the output from your jobs.

Scheduling recurring jobs
Although at is good for running commands at a specific time, it’s not useful
for running a program automatically at repeated intervals. You have to use
crontab to schedule such recurring jobs — for example, if you want to back
up your files to tape at midnight every evening.

You schedule recurring jobs by placing job information in a file with a spe-
cific format and submitting this file with the crontab command. The cron
daemon — crond — checks the job information every minute and executes
the recurring jobs at the specified times. Because the cron daemon
processes recurring jobs, such jobs are also referred to as cron jobs.

Any output from a cron job is mailed to the user who submits the job. (In
the submitted job-information file, you can specify a different recipient for
the mailed output.)

Two configuration files control who can schedule cron jobs using crontab:

Page 816

6. Each time you redistribute the Program (or any work based on the Program), the recipient
automatically receives a license from the original licensor to copy, distribute or modify the
Program subject to these terms and conditions. You may not impose any further restrictions
on the recipients’ exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.

7. If, as a consequence of a court judgment or allegation of patent infringement or for any other
reason (not limited to patent issues), conditions are imposed on you (whether by court
order, agreement or otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent obligations, then
as a consequence you may not distribute the Program at all. For example, if a patent license
would not permit royalty-free redistribution of the Program by all those who receive copies
directly or indirectly through you, then the only way you could satisfy both it and this
License would be to refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under any particular circum-
stance, the balance of the section is intended to apply and the section as a whole is intended
to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any patents or other property
right claims or to contest validity of any such claims; this section has the sole purpose of
protecting the integrity of the free software distribution system, which is implemented by
public license practices. Many people have made generous contributions to the wide range
of software distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to distribute software
through any other system and a licensee cannot impose that choice.

This section is intended to make thoroughly clear what is believed to be a consequence of
the rest of this License.

8. If the distribution and/or use of the Program is restricted in certain countries either by
patents or by copyrighted interfaces, the original copyright holder who places the Program
under this License may add an explicit geographical distribution limitation excluding those
countries, so that distribution is permitted only in or among countries not thus excluded. In
such case, this License incorporates the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions of the General
Public License from time to time. Such new versions will be similar in spirit to the present
version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies a version
number of this License which applies to it and “any later version”, you have the option of fol-
lowing the terms and conditions either of that version or of any later version published by
the Free Software Foundation. If the Program does not specify a version number of this
License, you may choose any version ever published by the Free Software Foundation.

10. If you wish to incorporate parts of the Program into other free programs whose distribution
conditions are different, write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free Software Foundation; we
sometimes make exceptions for this. Our decision will be guided by the two goals of preserv-
ing the free status of all derivatives of our free software and of promoting the sharing and
reuse of software generally.

Page 817

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE
PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFOR-
MANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIB-
UTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING
ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

Similer Documents