We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Software

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What is a Cron Job?

By Shannon Kietzman
Updated: May 16, 2024
Views: 15,824
Share

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.

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.

Share
EasyTechJunkie is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.
Discussion Comments
By investment01 — On Mar 11, 2009

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 your 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.

Share
https://www.easytechjunkie.com/what-is-a-cron-job.htm
Copy this link
EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.

EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.