Coral: cron intro

From The Uniform Server Wiki
Jump to navigation Jump to search

CRON - Introduction

Cron originated in the Unix environment. It is a job scheduler, allowing scripts to be run automatically at a certain time or date. The name was based on the Greek word for time, "chronos" .

The Uniform Server’s portable Cron plugin has been integrated into 8.0-Coral. Cron's configuration file has been pre-populated with various scripts to be run. These are essentially four-line templates that require enabling to run the appropriate applications from the Cron script.

The Uniform Server provides a simple user control interface to start and stop Cron as a standard program. Alternatively, you can install Cron as a service.


UniServer 8-Coral
  Home
  Quick Start
  General
  Apache
  MySQL
  PHP
  MSMTP
» CRON
  DtDNS
  Db Backup
  Perl
  Main Index

Features

  • Configuration file pre-configured for common applications.
  • Run Cron as a standard program
  • Run Cron as a service
  • Run scripts with the following file extensions: .bat, .vbs and .php
  • Pre-configured to run DtDNS, DBbackup and Drupal cron jobs

Configuration file

Each script to be run requires a configuration entry in the configuration file cron.ini. Open this file in the default editor using UniController as follows:

UniController: Server Configuration > Cron > Edit Cron Configuration

  • Each script to be run requires a configuration block. Two examples are shown at right.
  • Comand-line scripts (.bat, .php, .vbs) require an absolute path to be specified.
  • Web-applications require a URL path. This URL path is what you would type into a browser to run that script.
  • Each script running a Command-line or Web-application is defined in a separate block with the following format:
[db_backup]
start  = 2009-09-21 2:56:52
period = hourly
path   = C:\UniServer\uni_con\db_backup\Run_db_backup.bat
ref =

[moodle]
start  = 2009-09-21 2:56:52
period = hourly
path   = http://localhost/moodle/admin/cron.php
ref =

Configuration block format

[dtdns] -- Each block starts with a unique name enclosed in square brackets. Note that no spaces are allowed.
start = -- Initial start time with the following format: Y-M-D H:M:S - Note: 24 hour clock.
period = -- How often to run the script from the above referenced start time
Values: hourly, daily, weekly, monthly or numeric in seconds
path = -- a) For a web application, the full URL of the script. e.g. http://localhost/drupal/cron.php
b) Command-line (CLI) uses an absolute path with back-slashes e.g. C:\UniServer\uni_con\cron\test_cron_1.bat
ref = -- A timestamp updated by cron script. Set initial value to blank


Note 1: Cron automatically updates ref. It initially adds period as set above to Start time. For subsequent runs, it sets ref to current time + period.

Note 2: To change start time, first set a new value for start and delete the ref number, then save the file. The script will run at the new date and time set and thereafter at the rate you defined for period.

Note 3: To use pre-configured CLI blocks for dtdns and db_backup, uncomment to enable.

Note 4: To use pre-configured web blocks for drupal and moodle, uncomment to enable.

Note 5: Command-line paths to scripts contained in sub-folders below UniServer are automatically updated (portable). Paths outside UniServer require a manual change.

Top

Cron Controller

Using Cron controller, portable Cron is run either as a standard program or as a service. Open the Cron controller as follows:

UniController: Server Configuration > Cron > Cron Controller

The Cron Controller consists of four buttons (B,C,D and E) as shown on right

  • Initially, both program B) and service D) buttons are enabled. When Cron is running, one of these buttons is disabled; for example, if it is running as a service the program button is disabled.


  • Run as a program: To run Cron, click the start button B). With Cron running, this button is disabled and the Stop button C) becomes enabled, allowing you to stop Cron.


  • Run as a service: To install and run Cron, click the start button D). With Cron running as a service, this button is disabled and the Stop and Uninstall Service button E) becomes enabled, allowing you to stop and uninstall Cron service.

Top

Logging

Cron logs the following information:

  • Time Cron was started
  • Start time and path of a script that is run.
  • Time Cron was stopped. Note: if this is missing from the log, it means the servers were not shutdown before the PC was turned off

Note: Cron logging is enabled by default. This can be disabled; see xxx for details.

Summary

The above has shown how easy Cron is to use and configure.

Note: If you enable either or both builtin CLI scripts (DtDNS updater, db_backup), remember to properly set their configuration files.

Where to next

CRON - Configuration detail


Top