Cron Jobs Tutorial - So you wanna learn Cron jobs huh ?

free web hosting
Free Web Hosting > Computers & Tech > How-To's and Tutorials > Websites and Web Designing

Cron Jobs Tutorial - So you wanna learn Cron jobs huh ?

OpaQue
How to setup Basic Cron Jobs.

Ok. Many people are yelling that they cannot configure the crons properly.
Here is a short tutorial which will help you set them. I have tried my best to explain the concept but there can be more advanced configurations.

Basically you will want to run a PHP script file in specific intervals. Suppose you want to execute a php file called maintanence.php every one hour. This is what you do :-

[ smile.gif This tutorial is for noobs, Dont go into detail. Just do as instructed smile.gif ]

The CRON Command is in the Following Format

CODE
[ Minute - Hour - Day - Month - Weekday ] - Command


The COMMAND, can be broken down in
CODE
[PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]


So the COMPLETE CRON command can be written as

CODE
[ Minute - Hour - Day - Month - Weekday ]  [PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]


The timing is spedified using * symbols
CODE

* * * * * => Execute every minute
0 * * * * => Execute every Hour
0 0 * * * => Execute every mid-night
0 0 0 * * => Execute every Month
0 0 0 0 * => Execute every Weekday


If you did not understand anything till now.. Good, this means you are a noob.. Read ahead tongue.gif

Since this is a UNIX command, You will have to Mention the PATH of PHP. At Astahost,
CODE
PATH TO PHP  : /usr/local/bin/php

( it also same at trap17, if users over there want to use it )

These are the Possible Command line Arguments you can use. This will effect the output. In our case, we will use the -q ( Quiet mode ) argument.
CODE

 -a               Run interactively
 -b <address:port>|<port> Bind Path for external FASTCGI Server mode
 -C               Do not chdir to the script's directory
 -c <path>|<file> Look for php.ini file in this directory
 -n               No php.ini file will be used
 -d foo[=bar]     Define INI entry foo with value 'bar'
 -e               Generate extended information for debugger/profiler
 -f <file>        Parse <file>.  Implies `-q'
 -h               This help
 -i               PHP information
 -l               Syntax check only (lint)
 -m               Show compiled in modules
 -q               Quiet-mode.  Suppress HTTP Header output.
 -s               Display colour syntax highlighted source.
 -v               Version number
 -w               Display source with stripped comments and whitespace.
 -z <file>        Load Zend extension <file>.


The Path of the PHP file Must be Complete absolute path.
If you have an Account at TRAP, And your USERNAME is "tom", Your path will be
"/home/tom/public_html/"

I assume you are familier with the PUBLIC_HTML directory. That is the Root folder where you store your html files.

So lets say that Tom wants to execute my script "maintenance.php" every hour. And it is stored in "public_html/cron/maintenance.php";

So the Complete CRON command would be,

CODE
0 * * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php


If tom wants to execute it every minute, he would use.

CODE
* * * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php


There are more Complex forms of Assigning the TIMINGS for these scripts. You can go to CPANEL => Cron Jobs => Standard and set exact time when the script will be executed.


Also, this method used php, you can also use Curl .

-OpaQue

 

 

 


Reply

yordan
Nice tuto, OpaQue.
I would just add a comment. I use the same syntax, but I add an output file, just in case something fails.
So, my crontabe line would be :
0 * * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php >/tmp/maintenance.txt 2>&1
With this syntax I redirect the standard output (which is something like "starting", then "finished") as well as the standard error (just in case something goes wrong) to /tmp/maintenance.txt and I am able to have a look in this text file for debugging purposes.
Yordan

Reply

iGuest
Great Help mates.....thanks alo
Cron Jobs Tutorial

Lookin for this longtime, it made my mind so clear now easily set cron jobs, thanks alot mate...



-reply by Arlsn

Reply

iGuest
How to automatic delete all records older than 6 months ?
Cron Jobs Tutorial

I have a database with somw tables and some records .
Into I insert name suername and date (of registration) for a user .

How can I with crone jobs automatically delete ALL the records older thatn 6 Months par example ?

I want it in PHP / Mysql ..Can anyone help me or give some example ?

I'll apreciate it , thanks in advance ;)

-reply by Jeremy

--- admin reply (trap17.com) ---
>> You have to make a PHP program that connects
>> to Database and Deletes those records.
>> Then you run this program in cron with
>> wget / curl / php command :-)

-shree

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. linux view crone jobs - 6.65 hr back. (1)
  2. cron job tutorial - 7.43 hr back. (2)
  3. crone jobs in linux - 11.31 hr back. (1)
  4. tutorial on cron job - 11.94 hr back. (1)
  5. writing cron jobs book - 18.05 hr back. (1)
  6. create a basic cron job - 19.15 hr back. (1)
  7. crone jobs for cpanel - 22.32 hr back. (1)
  8. writing a crone job on windows server - 34.01 hr back. (1)
  9. cron job example - 38.50 hr back. (1)
  10. php delete image every month cron jobs - 39.36 hr back. (1)
  11. cron jobs tutorial - 39.92 hr back. (1)
  12. deletion by cron in php - 44.48 hr back. (1)
  13. how to do cron jobs in fedora - 44.73 hr back. (1)
  14. how do i edit cron in fedora 9 - 50.35 hr back. (1)
Similar Topics

Keywords : cron, jobs, tutorial, wanna, learn, cron, jobs, huh

  1. Gimp Animation Tutorial
    Read in the first part of the tut why i made another tut same as Lance (2)
  2. Here Are Some Great Php Tutorial Sites
    (4)
    these site very usefull for php html java 5 day ago i only use w3school recently i have some great
    web for usefull http://www.devresources.net/ http://www.php.net/ http://www.tizag.com/phpT/
    http://www.w3schools.com/php/default.asp http://phpbuilder.com/ http://www.phpfreaks.com/
    http://www.w3schools.com/php/ http://www.hudzilla.org/phpbook/index.php
    http://www.spoono.com/ http://codewalkers.com/ http://www.phpcs.com/ http://pear.php.net/
    http://www.phpclasses.org/ http://phpdebutant.org/ http://www.phpfrance.com/ http://....
  3. How To Understand A Database Schema
    A very nice and simple tutorial (4)
    Yesterday while i'm seaching for a data model and database schema at the Library of Free Data
    Models for a new project of a friend of mine i found there this nice and simple tutorial on How to
    Understand a Database Schema . As its name says, this tutorial will help you to better understand a
    Database Schema and covers the following basics topics that every Database Schema must define:
    QUOTE Primary and Foreign Keys. One-to-Many and Many-to-Many Relationships. Inheritance.
    "Rabbit's Ears", (Recursive relationships). The Scope of this tutorial is ....
  4. Psychostats
    Psychostats tutorial for cs (1)
    QUOTE Required Server Software A Web server (usually Apache or IIS) PHP v4.3 or any version
    higher. MySQL v4.1.11 or any version higher. Windows ActivePerl v5.8 or v5.10 Linux Perl v5.8+
    Required Perl modules DBI (v1.4 or higher) DBD::mysql (v3.0002 or higher) Optional Perl modules
    Net::FTP - This is only required if you need to download logs from a remote FTP server (chances are
    this will be installed by default with your version of Perl). Net::SFTP - This is only required if
    you need to download logs via an SFTP server (secure SSH file transfer protoco....
  5. Basic Html Tutorial
    Made it myself, hope you like it. (1)
    HTML stands for hyper text markup language. It is a basic coding language used on almost every
    website. There are some tags in HTML which must be used, whilst others are enhancing, but not
    essential. Below I shall list the essential tags and there uses: This tells the browser that
    the language between the tags is going to be HTML so it knows how to read it. Inbetween those tags
    come These tags tell the browser that all the content that you wish to be displayed is in there.
    They are the only essential tags for HTML! The list is short but if you only use them y....
  6. Is It Possible To Make Php Scripts Executed Without A Cron?
    (2)
    Title says it all really. Just wondering if it's possible in an way? If so could anyone tell
    me?....
  7. Moving To Fedora 9
    Tutorial on how a newbie can move to using this fantastic OS Fedora 9, (1)
    INTRODUCTION Through this Post/ tutorial, I will try to explain to newbies and experts an
    smoothly moving to Fedora 9. Also, I would explain only those topics that are hard to find on net,
    or are not well documented anywhere. These are my experience of using Linux/Fedora. Motto: More
    and more people realize and get FREE from all the GATES and WINDOWS. Table Of contents 1.
    Installation 2. Setting the Stage 3. Get set n Go 3.1 Play Anything 3.2 Read anything 3.3
    Desktop utilities 3.4 Connect ADSL 4. Tips and Tricks 5. Remarks. Remark: This....
  8. Bulletproof Ftp Server Tutorial
    BulletProof FTP Server Tutorial (0)
    thanks to someone for this tut. Configuring your Bulletproof FTP Server Tutorial I am not sure
    where I found this tutorial, It’s been a while…It might even have been here... ..So if it is one of
    yours, my hat goes off to you once again.... After reading the excellent tutorial on "Creating an
    FTP" that Norway posted… (I would suggest reading and following his tutorial first, then following
    up with this one) I thought that perhaps this tutorial might be pretty helpful for those interested
    in knowing how to configure their Bulletproof FTP Server that don't already ....
  9. Choosing Your Computer Before Bying
    Learn how to choose the best computer (4)
    I decided to make this topic because i know there are a lot of people out there that don't know
    what kind of computer they should buy. If you are ready for a new computer either get someone that
    knows more about computers than you, OR read this topic /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> 1. Choosing your
    motherboard The motherboard is the basic thing a computer should have. It is connecting all the
    other parts to each other. When you are choosing a motherboard you first need to know what graphics
    port does it have....
  10. Gimp Userbar Tutorial
    Very Easy... (3)
    Hello, I will tell you how to create a nice userbar in the open-source software called GIMP. You
    should GIMP 2.4.6 installed on computer, and if you don't, go to The GIMP Website. Make sure
    to view a few beginner tutorials to have a basic understanding of GIMP. This is what the finished
    userbar will look like: It is very simple, and I learned it easy. I will guide you through all
    the steps of making a userbar. ~ Now we will go through all the steps. 1. Open GIMP and click
    New(Ctrl + N) and make the size for your new image 350 by 19. Your screen should look....
  11. C/c++ -gdb Linux Debug Tool
    Simple Gdb tutorial (1)
    To run the C/C++ file use $ gcc –g –o test sample.cpp To debug the code use following
    command $ gdb test --- you will get following messages GNU gdb Red Hat
    Linux (6.3.0.0-1.122rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered
    by the GNU General Public License, and you are welcome to change it and/or distribute copies of it
    under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty
    for GDB. Type "show warranty" for details. This GDB was configured as "i386-redh....
  12. Linux Beginners - Tutorial On Editors In Linux.
    (3)
    This is a simple tutorial on the editors in Linux. I use these 3 editors for programming on linux:
    1. vi -- available in all Linux and unix box, used to edit 2. vim -- not in all Linux flavors
    and it has got default coloring of key words feature, used to edit 3. view --Its used only to
    view, recommended to use for viewing of system config files, as it should not get edited without
    your notice. Following are the basic commands comes handy with these editors #Open a file for
    edit $ vi test -- creates a file if file is not exist in the current director....
  13. Photographing Fireworks
    Tutorial for shooting fireworks (7)
    Photographing fireworks presents some technical challenges, it needs quite a different approach to
    most other subjects but follow these few steps carefully and you will be successful. What are we
    photographing? Basically we are photographing streaks of light that develop over a period of time
    against a black background. The great thing about a black background is that it makes no impression
    on the film, or sensor in the case of a digital camera. So we can leave the shutter open as long as
    we like, the black will still be black. So, in short, the way to photography firew....
  14. How To Download Videos From Youtube
    A Tutorial designed to inform of how to download YouTube videos. (11)
    This tutorial is to inform the reader of how to download videos from YouTube. I will also inform
    you of how to convert these videos into MP4 format so you can put them on your iPod. First, download
    Mozilla Firefox Internet Browser. This is, in my opinion, the most secure and customizable browser
    available. It can be downloaded freely at http://www.firefox.com . After you have Mozilla Firefox
    installed, open it and go to: http://www.firefox.com . When the page has finished loading, click
    Add-ons at the top of the page. Once the page has loaded, click in the search....
  15. Safety
    Anyone who knows a tutorial (9)
    Hey! Anyone who know a tutorial where they teach you how to protect your scripts from danger
    (hacks and stuff)? I think I need to start to think about theese stuff now.....
  16. How To Make An Test-based Rpg Game!
    This is a step by step tutorial of how to make a RPG test-based game (4)
    Welcome Hello this is Convictlife and i have made an RPG game and for you noobs out
    there i will be explaining Here is a breif structure of this post: 1. Getting your codes. 2.
    Getting your host. 3. Uploading your codes. 4. Configuring your codes. 5. MySQL 6. phpMyAdmin 7.
    CronJobs 8. Editing 9. Finalizing Getting Your Codes! First of all you need codes that
    will power your website. If you are a master coder (like Dabomstew) then you can code these codes
    yourself, but if you are "so-so" then you will need to get codes from somewhere. I got....
  17. Html Basic Tutorial
    <!-- For beginners only --> (9)
    Knowledge HTML stands for H yper T ext M arkup L anguage. You cannot create an HTML file
    using a rich-text editor, such as Microsoft Word or Wordpad. HTML To write a basic HTML, you will
    need to start with this: CODE <html> The html > tag tells the browser that this is
    an HTML page. To close any tag, the same tag will be repeted but with the "/" sign. For example,
    CODE <html>   <head>     <title>Page title</title>
      </head> </html> Did you notice the /title >, /head > & /html > tags? Th....
  18. Php Tutorial: Making A Shoutbox
    Requirements: PHP, MySQL (11)
    Hi everyone, I'm going to tell you how to make a simple shoutbox using PHP and MySQL. To start
    off, open up mysql in the command line, or phpmyadmin, and create a database called shoutbox. Next,
    enter the following sql into the command line, or the phpmyadmin sql box, while using the shoutbox
    database: CODE create table messages(author varchar(30), message text, time
    timestamp, mid int auto_increment, primary key(mid)); This creates the table we need
    to store the messages, note the "mid" column, this gives each message a seperate id nu....
  19. Phpbb - Installation Tutorial ( For Newbies Based On Astahost Cpane)l
    phpBB 2.0.22 installation Tutorial with basic steps. (5)
    Introduction!! Providing a comprehensive 'How To' tutorial guide, on the
    installation of phpbb 2.0.22 forum on your Astahost/cPanel account. Tutorial includes Downloading
    of files Uploading using cPanel File Manager CHMOD using cPanel File Manager MySQL database
    creation PhpBB initial configuration This guid will help everyone from beginners, with images and
    an in depth guide of what to do. Step 1 To start with we need to download PhpBB ( latest stable
    version is PhpBB 2.0.22 ). This can be done by visiting the PhpBB Downloads page wh....
  20. Wireless: Bypassing Mac Filtering
    Tutorial (10)
    Sometimes you scan the neighborhood for the wireless connections, you see open connections but can
    not connect to them. Well this is possible because they use MAC filtering to secure up their
    network. I will try to explain how to bypass this protection NOTE: This is for EDUCATION purpose
    only to show you it is possible to bypass this security. I am not responsible for unauthorized use
    of these information. Requirements : 1- You need some tool for sniffing the traffic. I suggest
    using Aircrack-ng (http://www.aircrack-ng.org/) 2- You need some tool to change your MAC ad....
  21. Installing Glut To Dev C++
    A tutorial to install GLUT on Dev C++ (3)
    This is a tutorial that someone submitted to my programming site when it was up because I didn't
    know how to install glut on any other compiler than my own. I though it would be helpful to post
    this up for everyone here so they can use GLUT as well without having to google for hours. I'm
    not sure if I'm allowed, but I have quoted it and have given credit where credit is due, so if
    this post is allowed I hope this helps those people who couldn't program in GLUT yet. QUOTE
    Installing G.L.U.T. to Dev C++ By James Duran (email: vrok137@yahoo.com) ....
  22. Pre Loader Tutorial For Flash
    Made by: Jordain (6)
    Simple pre loader tutorial with play button by: Jordain Joyce First of all open up flash then
    Create 4 Layers and in order name them: Actions
    Loader outline
    Loader Bar Content Then create 3
    frames for each layer. Lets start in the actions layer, for the first frame make it blank and the
    second frame make it blank also. Press F9 to open the actions panel (make sure you ....
  23. Using The Php Mail() Function For Images Or Attachments
    Can't find a decent tutorial! (3)
    I read the one mail() tutorial that was posted in the tutorial section and to my horror found that
    he had quoted almost verbatim from the PHP Manual off php.net, and made a comment about it, and also
    found that if you were new to PHP or the Manual that it was informative but not indepth enough for
    my tastes. This is not a tutorial although with the code that will be posted it might look like
    one, that is not its intent or purpose. I have searched and found many so called tutorials about
    MIME mail and boundries and all that but basically it either told me to use PHPMai....
  24. VB.NET: MS-Access Interaction Tutorial (Part I)
    (18)
    VB.NET - MS-Access Interaction Tutorial I got down to writing this tutorial because of
    this certain question that Dhanesh posted on our forums here . This tutorial will attempt to
    show you how to: Create a MS-Access Database Create/Edit/Delete Tables in it Access it and
    Add/Edit/Update data in those tables all with VB.NET . Note: This is not a beginner's
    tutorial and I'll assume you know all the basics of creating WinForm based applications using
    VS.NET . The screen-shots provided are from VS.NET 2005 - but you shouldn't f....
  25. Photoshop Tutorial: Full Grunge Signature
    Using Photoshop 8.0 CS (16)
    Side Notes: I hope you enjoy it. I made this awhile ago, but didn't posted it before. I
    though it was time to be shared, so here it is. ....
  26. C#.NET: Web Timer Control Tutorial
    C# & VB.NET (3)
    Web Timer Control C# Difficulty: Easy Time: 10 Minutes The aim of this tutorial is to create a
    Timer that works on web pages. Timers are a very useful control in Windows Applications but how can
    you use them in web pages. With the default controls you get in the .Net Framework there is not a
    Web Timer. This web timer can be used as a normal web control you will be able to drag and drop it
    onto Web Forms, and modify it using the properties window. This Timer Works using the JavaScript
    setTimeout() function which once the required time has elapsed unlike a Windows F....
  27. 3ds Max Tutorial #2-creating Reflective Materials
    (1)
    The next tutorial is based on creation of a reflective material in 3ds max. this tutorial will help
    u create a surface that reflects everything in sight. 1. Fire up 3dsmax. 2. Press 'm' 3.
    Change the box where u see 'Normal' i.e. material type. Change it to raytrace. 4. Change the
    colours to the colours you want. 5. In the maps section click the box next to reflection. 6. Select
    raytrace from the list. 7. Apply the material to any object. 8. Render the scene
    Voila!!! you have created a reflective material. You can also try.. 1. Using the ....
  28. Online Multiplayer Game
    What language to learn in order make it? (16)
    If you look at e.g. THIS LINK What language would you use to make something like that?
    /wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' /> ....
  29. 3ds Max Tutorial.
    Introduction to reactor. (7)
    Letter Collision Tutorial. This tutorial will help u make a basic collision in 3Ds Max using its
    inbuilt reactor feature. Requisites:- discreet 3Ds Max 7 (Does 6 have reactor?? I dunno....). Even
    the trial downloaded from discreets website will do. Time:- 20-30min. Skill Level :- Beginner (A
    basic knowledge of the menu items is a must for this tutorial) Introduction:- reactor is a plug-in
    for 3ds max that allows animators and artists to easily control and simulate complex physical
    scenes. reactor supports fully integrated rigid and soft body dynamics, cloth sim....
  30. How To Remove Bad Sectors Or Bad Clusters From HDD
    a tutorial for you all (17)
    hi friends, there is small tutorial to remove Bad Sectors from hdd to remove bad sectors you need a
    program named SeaMap now we start Start the SeaMap.exe software Set the option by typing SD and
    then press enter Press 1 then 0 or 1 to select drive Then press 2 and there will be a option (Y/N)
    press n for No Press Esc button one to go back to command line Type FD Type y for yes the Hdd will
    format the whole disk and removes bad sectors and partitions Now the computer has to be restarted,
    Restart your computer Partition your Hdd using fdisk and then format all partitio....

    1. Looking for cron, jobs, tutorial, wanna, learn, cron, jobs, huh

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for cron, jobs, tutorial, wanna, learn, cron, jobs, huh
Similar
Gimp Animation Tutorial - Read in the first part of the tut why i made another tut same as Lance
Here Are Some Great Php Tutorial Sites
How To Understand A Database Schema - A very nice and simple tutorial
Psychostats - Psychostats tutorial for cs
Basic Html Tutorial - Made it myself, hope you like it.
Is It Possible To Make Php Scripts Executed Without A Cron?
Moving To Fedora 9 - Tutorial on how a newbie can move to using this fantastic OS Fedora 9,
Bulletproof Ftp Server Tutorial - BulletProof FTP Server Tutorial
Choosing Your Computer Before Bying - Learn how to choose the best computer
Gimp Userbar Tutorial - Very Easy...
C/c++ -gdb Linux Debug Tool - Simple Gdb tutorial
Linux Beginners - Tutorial On Editors In Linux.
Photographing Fireworks - Tutorial for shooting fireworks
How To Download Videos From Youtube - A Tutorial designed to inform of how to download YouTube videos.
Safety - Anyone who knows a tutorial
How To Make An Test-based Rpg Game! - This is a step by step tutorial of how to make a RPG test-based game
Html Basic Tutorial - <!-- For beginners only -->
Php Tutorial: Making A Shoutbox - Requirements: PHP, MySQL
Phpbb - Installation Tutorial ( For Newbies Based On Astahost Cpane)l - phpBB 2.0.22 installation Tutorial with basic steps.
Wireless: Bypassing Mac Filtering - Tutorial
Installing Glut To Dev C++ - A tutorial to install GLUT on Dev C++
Pre Loader Tutorial For Flash - Made by: Jordain
Using The Php Mail() Function For Images Or Attachments - Can't find a decent tutorial!
VB.NET: MS-Access Interaction Tutorial (Part I)
Photoshop Tutorial: Full Grunge Signature - Using Photoshop 8.0 CS
C#.NET: Web Timer Control Tutorial - C# & VB.NET
3ds Max Tutorial #2-creating Reflective Materials
Online Multiplayer Game - What language to learn in order make it?
3ds Max Tutorial. - Introduction to reactor.
How To Remove Bad Sectors Or Bad Clusters From HDD - a tutorial for you all
advertisement




Cron Jobs Tutorial - So you wanna learn Cron jobs huh ?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE