Category: 

What is a Cron Job?

Article Details
  • Written By: Shannon Kietzman
  • Edited By: Niki Foster
  • Last Modified Date: 14 October 2014
  • Copyright Protected:
    2003-2014
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
Atlanta's Hartsfield-Jackson International Airport is the world's busiest with 94 million passengers annually.  more...

October 26 ,  2001 :  US President George W. Bush signed the USA PATRIOT Act.  more...

A cron job is an automated program developed for Unix and Linux systems. It allows the user to execute several commands at a specific time on a precise date. A cron job is an important tool that can be used for anything from running scripts and re-indexing a web page to providing backup for a database. A cron job can also be used as a reminder for downloading email. The user only needs to set the program up once in order for it to continuously complete the job.

If a web e-zine owner has over 100 email subscribers reading his publication on the 25th of each month, for example, a cron job could assist in getting the information out to each reader at the same time and date each month. In addition, it can add new members to the web site and remove those who unsubscribe while maintaining the database.

A cron job is set up with cron tabs within a cron tab manager. Cron tabs are divided into six fields: minutes, hours, days, months, weekdays, and commands. The command field provides instructions to the computer. The minute field runs from 0-59 and gives the exact minute the command is to be executed. The hour is set between 0-23, with zero representing midnight.

Ad

The days of the week run from 0-7, with both 0 and 7 representing Sunday. Some older systems, including some Unix systems, use 0 through 6 as the days of the week, 0 being Sunday. White spaces or tabs must separate each field. Commas are used when adding a list, while asterisks are added where the user does not wish to specify a field. For the aforementioned web e-zine owner, for example, the cron job can be set up with an asterisk in place of the day of the week because the 25th day of the month will not always fall on the same weekday.

A cron job is written in a text file with a series of cron commands for the computer to adhere to. Preparing a cron job as a text file also makes it easier to edit the scripts later if needed. In addition, the cron job can be set up to either allow or deny certain users from tweaking the set cron tab. Once the text is created for the cron job, it is followed by a .txt extension, such as Cron.txt. Then, the job is uploaded and the text file's accompanying command would read as "crontab cron.txt" before it takes effect on the web page.

Ad

More from Wisegeek

You might also Like

Discuss this Article

investment01
Post 1

My cronjobs file has in 1st 5 lines:

#!/usr/local/bin/php

= '4.0') {

chdir(getcwd());

}

include("../conf.inc.php");

include("../functions.inc.php");

if (system_value("cronjobs_ran_at")>time()-290){

And I got an installation information file written:

This is the cron job you or your programmer needs to create (all on one line - No carriage returns.)

* * * * * /PATH/TO/lynx --dump http://PUT_YOUR_DOMAIN_NAME_HERE/scripts/admin/cronjobs.php > /dev/null

(Replace "PUT_YOUR_DOMAIN_NAME_HERE" with *your* domain name

Now I don't know where to write this and I read ur article I want my database or host to read the cron job file every minute ... please tell me where I have to write those lines and what the procedure is. Please tell me as I'm not a script expert.

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email