What is Cron job?

Discussion in 'PHP/MySql' started by balajia, Jul 27, 2010.

  1. balajia New Member

    Member Since:
    Jul 1, 2010
    Message Count:
    27
    Likes Received:
    1
    Occupation:
    Web Developer
    Location:
    India
    In your project you might have to run a function or script (.php) file automatically for a various reasons like automatic sending email on birthday or automatically close a auction when the end_time is reached. What to do in that situation? .To do these things automatically, you must have a php file which must contains the code and these files should be called automatically at certain certain time. So how to do that? The answer is Cron Job. Cron job are the cron tab command found in the UNIX or Linux system.
    Now let’s see how can we call the file automatically at certain duration. Let’s suppose the duration is one hour, now I’ll show you how to setup the the cron-job of every one hour to run a PHP file automatically in the Cpanel of your website.


    1. Go to the Cpanel of your website.
    2. Click on cron-tab.
    3. Now there are two options Standard and Advance(Unix Style).
    4. Click on the Standard – Now select minutes to “0″ , Hours to every hour, month, days , weekdays to every option.
    5. And in the command to run text box enter “lynx -source http://your-domain/your-file.php > /dev/null“. As you can see the command called lynx which is a browsing program in Unix/Linux system and call the specified php file in every hour.
    6. To setup Advance(Unix Style), just click on that button and place 0 on minute and * on the hour, day , month and weekday and in the command just place “lynx -source http://your-domain/your-file.php > /dev/null“. The “*” means that every i.e. “*” in hour means that every hour, the same in day means that every day etc.

    In the other control panel like Plesk have different environment where you can enter the the following command directly

    0 * * * *

    lynx -source http://your-domain/your-file.php > /dev/null Where 0 represents every 0th minute, the next “*” means every hour, the next “*” means every day, the next represent every month and the last one represent every weekday.
  2. DaveAlbury New Member

    Member Since:
    Aug 18, 2010
    Message Count:
    15
    Likes Received:
    0
    i have been wondering what this is for ages
  3. SeoKungFu Active Member

    Member Since:
    Jul 10, 2009
    Message Count:
    688
    Likes Received:
    84
    Occupation:
    SEO NinJah
    For the sake of clarity I would add that any command or custom executable script can be set to run at certain time with precision up to 1 min.
  4. SeoKungFu Active Member

    Member Since:
    Jul 10, 2009
    Message Count:
    688
    Likes Received:
    84
    Occupation:
    SEO NinJah
    but there are no other places like 127.0.0.1 and /dev/null , sigh :)
  5. PradeepKr New Member

    Member Since:
    Aug 16, 2010
    Message Count:
    22
    Likes Received:
    0
    Few cents from me,

    You can add 2>&1 also to redirect the errors/warnings also to the empty file (/dev/null)

    Code (text):
    0 * * * * "your_command_to_run" > /dev/null 2>&1
  6. earln7 New Member

    Member Since:
    Jan 24, 2011
    Message Count:
    69
    Likes Received:
    0
    been wondering what this is for ages any info.
    ============
    Earl Nunes
  7. earln7 New Member

    Member Since:
    Jan 24, 2011
    Message Count:
    69
    Likes Received:
    0
    Want to read more.
    ==========
    Earl
  8. jaikanth12 Member

    Member Since:
    Jan 9, 2010
    Message Count:
    491
    Likes Received:
    11
    Cron is a time-based job scheduler in Unix-like computer operating systems. The name cron comes from the word chronograph (a time-piece). Cron enables users to schedule jobs (commands or shell scripts) to run automatically at a certain time or date. ...

Share This Page