WARNING: This site is intended for online use only; mass-downloading of pages degrades the server and is prohibited.
If you attempt to use tools to mass-download the site, you may be blocked permanently by automated software.
If you want to read this CertiGuide offline, please use one of the links on the left to purchase a convenient PDF copy. Thank you.

Like what you see? Get it in one document for easy printing!
Click Here!

Custom Search






Table Of Contents  CertiGuide to A+ (A+ 4 Real)
 9  Chapter 5: The Linux Operating System
      9  Command Line Functions And Administrative Utilities
           9  Scheduling Processes For Later Execution

Previous Topic/Section
at  - Queue Jobs For Later Execution
Previous Page
Pages in Current Topic/Section
1
Next Page
Package Management
Next Topic/Section

cron/crontab - Execute Scheduled Commands

cron is a daemon that monitors the /etc/crontab file on a regular basis, to find commands that are scheduled for repetitive execution at various times. The crontab command is used to add entries to this file so that task can be run. An example crontab file is:

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

 

# run-parts

01 * * * * root run-parts /etc/cron.hourly

02 4 * * * root run-parts /etc/cron.daily

22 4 * * 0 root run-parts /etc/cron.weekly

42 4 1 * * root run-parts /etc/cron.monthly

Of interest are the initial fields, in the lines underneath the entry # run-parts. The first field (of five which are separated by spaces) contains the minutes (0 -59), the second - the hour (0-23), the third - the day of the month (1-31), next the number of the month (1-12), and finally the day of the week (0-7, both 0 and 7 are Sunday). An asterisk (*) in any field selects the whole range of that field. Reading the last entry in the above example shows that this command will run at the 42nd minute, the fourth hour of the first day of the month (at 4:42 am on the first of the month).

A text file can be created containing the time specification followed by at the command (or a script file) that is to be executed. Such as:

8 03 3,18 * * payroll

If it is saved with a file name of payrollcron. Then the crontab command can be used as follows:

crontab payrollcron

This would cause the contents of the file payrollcron to be submitted to the cron daemon to run. The file payroll would be run on the third and 18th of the month at 3:08 A.M.


Previous Topic/Section
at  - Queue Jobs For Later Execution
Previous Page
Pages in Current Topic/Section
1
Next Page
Package Management
Next Topic/Section

If you find CertiGuide.com useful, please consider making a small Paypal donation to help the site, using one of the buttons below. You can also donate a custom amount using the far right button (not less than $1 please, or PayPal gets most/all of your money!) In lieu of a larger donation, you may wish to consider buying an inexpensive PDF equivalent of the CertiGuide to A+ (A+ 4 Real) from StudyExam4Less.com. Thanks for your support!
Donate $2
Donate $5
Donate $10
Donate $20
Donate $30
Donate: $



Home - Table Of Contents - Contact Us

CertiGuide to A+ (A+ 4 Real) (http://www.CertiGuide.com/apfr/) on CertiGuide.com
Version 1.0 - Version Date: March 29, 2005

Adapted with permission from a work created by Tcat Houser et al.
CertiGuide.com Version Copyright 2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.