Jump to content
xisto Community
Sign in to follow this  
OpaQue

So You Wanna Learn Crons Huh?

Recommended Posts

Ok. Many people are yelling that they cannot configure the crons properly.

Here is a short tutorial by "me" which will help you set them

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

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

The CRON Command is in the Following Format

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

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

So the COMPLETE CRON command can be written as

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

The timing is spedified using * symbols

* * * * * => 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 :P

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

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.

  -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,

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

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

0 0 * * * /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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.