Web Hosting Articles

  Home arrow Web Hosting Articles arrow Page 4 - What is CRON and What Can it Do?
Web Hosting Articles  
Web Hosting FAQs  
Web Hosting How-Tos  
Web Hosting News  
Web Hosting Reviews  
Web Hosting Security  
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB HOSTING ARTICLES

What is CRON and What Can it Do?
By: Rich Smith
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 17
    2006-06-28

    Table of Contents:
  • What is CRON and What Can it Do?
  • Cron for website and system maintenance
  • Cron for customer contacts
  • Cron without training wheels

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     

    SEARCH WEB HOSTERS

    TOOLS YOU CAN USE

    advertisement

    What is CRON and What Can it Do? - Cron without training wheels


    (Page 4 of 4 )

    For those of you without a nice GUI to configure your cron, you will need to go inside the crontab directly to configure it.  The file is located at /etc/crontab.  When Linux is installed, your crontab might look a little like this:

     

    The above file excerpt is how Redhat’s cron looks after installation.  It is separated into two parts.

    The first part, at the top, sets some variables for the cron when it runs.  It sets which shell to use, which folders to search, and a couple other things.  These are self explanatory.  The difficulty comes when you get to the bottom part.  See all of those numbers and asterisks(*)?  Those are used to configure when a cron is run, who it runs as, and what it executes.

    In the above example, the first scheduled job runs at one minute after the hour, every hour.  How did I know that?  Let's take a quick look at how the file is configured.  The columns are, in this order:

    1) Minute (0-59)
    2) Hour (0-23)
    3) Day of month (1-31)
    4) Month (1-12)
    5) Day of week (0-7 0 and 7 are BOTH Sunday)
    6) User to run cron as
    7) Command to execute when the cron runs

    For option you don’t want to specify a value, * is used as a placeholder.

    In the above example, the third scheduled task runs at 4:22am, every Sunday.  It executes the command “run-parts /etc/cron.weekly” as root.

    Simple right?

    One last thing I’d like to touch on is the "run-parts" option you see in the included example. This script causes all files within a folder to be executed.  In the above example, the cron would execute at 4:22 AM on Sunday, and every executable file inside /home/cron.weekly would be executed.  This makes it easy to schedule jobs at regular intervals without the need to modify the crontab directly each time.

    Final Thoughts

    As I said earlier, cron is only available on Linux or other Unix variants.  Windows has something called the task scheduler which I will not be getting into.

    As you have seen during this introduction, cron can add both complexity and simplicity to your system at the same time. The ability to schedule mundane tasks makes it easy for one person to feasibly run and maintain multiple servers and websites.

    In this article, I talked about what cron is used for, and gave some real-life examples where cron has been utilized to enhance the functionality of a site, while at the same time freeing up the server admin from most of the mundane tasks they do on a repeated basis. 

    I hope I’ve been able to give you enough of an understanding about cron to enable you to decide whether you need to use it.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    WEB HOSTING ARTICLES ARTICLES

    - Top Wordpress Plugins for SEO
    - Top Drupal Evaluation and Rating Modules
    - Free Network Monitoring Programs for Max Per...
    - E-store Hosting: Free Options for Beginners
    - Dropbox: The Ultimate File-Sharing and Synci...
    - Reviewing the Best Free Web Hosting Sites
    - Businesses Turn to Reseller Web Hosting for ...
    - Multiple Data Center Hosting
    - Web Hosting Goes Green
    - Web Hosting Technology Overview
    - Collaborate: An Examination of Tools for Gro...
    - Social Networking Security
    - Domain Names 101
    - Top Software to Help Manage Your Websites
    - The Evolution of Phishing

    Developer Shed Affiliates

     




    © 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap