Establishing a cron

0
Your rating: None

A cron is a service on Unix servers that allows tasks to be scheduled and executed automatically. The cron application runs constantly and will, according to instructions, carry out its orders. These orders are stored in a file called crontab. This file is a to-do list that contains lines that might look like this:

30 22 * * * lynx --dump http://www.kiran.org.in > /dev/null

The crontab format dictates that each line contain six fields separated by spaces or tabs. The first five fields represent, in order, minutes, hours, days, months, and day of the week (from 0 to 6, with 0 being Sunday).
Notice that you can specify the day of operation as either a day of the month (1–31) or a day of the week (Sunday through Saturday), the latter being date-indifferent.

An asterisk as one of the first five parameters means that value is not limited (i.e., it always applies). In the preceding example, the instruction is to be carried out at 10:30 P.M. (22 being 10 P.M. on the 24-hour clock) every day of the month, every month of the year. You can also set ranges using the hyphen
(1–6 for the month field would mean that the job applies to the first six months of the year) or list elements separated by comma(1, 3, 5 for Monday, Wednesday, Friday). The sixth field on each line is the task itself.
Looking at the preceding example, the actual command is to open the URL
www.kiran.org.in with Lynx, a textbased Web browser built into Unix.
The --dump and > /dev/null tell Lynx to close itself after viewing the site and not to store the information accessed.

Another example would be:
0 1 * * 1-5 mail –s ‘Howdy’ kiran@kiran.org.in

This line states that from Monday through Friday (1–5), at 1 A.M. (0 minutes, 1 hour) every day of the month and every month of the year (* *) it will send me an email (apparently I like email).

To use cron to run a PHP script, you have a couple of options. The first is to use the server’s own Web browser—like Lynx or Wget—to run a PHP script. Another would be to use the server’s installation of cURL.

This program works very well with URLs, although it’s not a Web browser, per se. A final option is to run the PHP script using the Command-Line Interface.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

SEO Architect,SEO Specialist reflect my values.

By enduring black hat methods the SEO industry is setting itself up for washout and sleepwalking into oblivion.

Jobs in India