FAQ / Databases, cron and backups

The Cron system tool

‹ Databases, cron and backups

What is Cron?

Cron is a program, a daemon running in the background of the operating system, that lets you run programs and scripts at time intervals or at a

specified time according to the user's settings.

Cron is suitable for repeated operations, such as daily generation of statistics, sending newsletters, recalculating database records, pre-building the cache, generating data warehouses, and so on.

How do I set up Cron?

Regular script execution can be set up for every web hosting.

If you are interested in getting this service running, contact us.

Important information

  • Cron can only call URLs pointing to the given web hosting on our servers. You cannot call other URLs or run commands on the command line.
  • It cannot be guaranteed 100% that cron will run at the exact given minute.
  • We recommend using some kind of locking system in your PHP script, in case cron runs several times because of a technical problem, which may be undesirable for your application
  • You cannot call a PHP script that requires HTTP authentication - solve this by adding an extra URL parameter with a password, without which the script cannot be run directly
  • Do not restrict the execution of the PHP script to a source IP address. We cannot guarantee that the IP address of the server that calls the scripts will not change. Solve this with another secret parameter in the URL as well.

What kinds of Cron schedules are there?

Running once per interval:

  • 1 hour - every full hour (at minute 0)
  • 2 hours - every even hour (at minute 0)
  • 4 hours - every fourth hour, starting at midnight (at minute 0)
  • 6 hours - every sixth hour, starting at midnight (at minute 0)
  • 12 hours - daily at midnight and at noon (at minute 0)

Hours of the day (from/to) - The range of hours during which the script should run each day.

  • the whole day - 0 to 23
  • part of the day - e.g. 11 to 15 or e.g. 22 to 2 (from midnight to 2 and from 22 to midnight)
  • only once a day at a specific hour - e.g. 11 to 11

Days of the week

  • On which days the script should or should not run (Monday to Sunday).

Date (from/to)

  • The range of dates during which the script should run, in the format YYYY-MM-DD. These settings are optional; you can leave them out or enter just one of the dates. The “to” date must not be earlier than today's date and must not be earlier than the “from” date.
  • If neither date is filled in, there is no date restriction. If only the “from” date is entered, the script will run from that date with no end. If only the “to” date is entered, the script will run from now until that date. If both dates are filled in, the script will run within that range.

Script URL - The address of the script that will be run periodically.

  • subdomain - a third-level domain
  • domain - a second-level domain pointing to your web hosting
  • script - the script name with any parameters in the URL

With these settings you can create a script address such as: http://www.vas-web.cz/cron/skript.php?data=123.

For the script to be run, the following conditions must be met:

  • the script's domain must point to our web hosting
  • the script must exist at the given address
  • it must be possible to determine the date of the next run from the configuration

Setup examples

Every hour, on weekdays from 8:00 to 17:00, until 23 December 2010

  • Run once per: 1 hour
  • Hours of the day: from 8 to 17
  • Days of the week: Monday to Friday
  • Date: to 2010-12-23

At 15:00, every day, from 1 January 2011

  • Run once per: 1 hour
  • Hours of the day: from 15 to 15
  • Days of the week: Monday to Sunday
  • Date: from 2011-01-01

Every 2 hours, except 6:00-16:00, every day

  • Run once per: 2 hours
  • Hours of the day: from 16 to 6
  • Days of the week: Monday to Sunday
  • Date:

Still not sure what to do?

Write to us and we will solve it together.

Contact support ›