User Tools

Site Tools

:: Version 2.2.0 ::

2_2_0:admin:cron
Translations of this page:

Background tasks

In order to operate properly, iTop maintenance operations and asynchronous tasks must be executed on a regular basis. In order to ease the installation, all the background tasks have been grouped to be launched from a single file: webservices/cron.php

The following features rely on the activation of cron.php

  • Asynchronous emails. By default, this option is disabled. To enable it, set 'email_asynchronous' to 1 in the configuration file
  • Check ticket SLA. Tickets reaching the limits will be passed into Escalation TTO/TTR states

Scheduling on Windows

Use schedtask.exe or the 'at' command to schedule cron.php to run every 5 minutes.

schtasks.exe /create /sc minute /mo 5 /tn "iTop CRON" /tr "\"/var/www/itop/webservices/cron.cmd\""

Scheduling on Linux

Edit the crontab to execute the script every 5 minutes:

 */5 * * * * root /usr/bin/php /var/www/itop/webservices/cron.php --param_file=/conf/itop/params >>/var/log/itop-cron.log 2>&1

Scheduling from the web

The page cron.php can also be executed through the web server. This is useful if you don't have access to the system (for example on shared hosting systems). In such a case you can rely on a web cron service to run it for you. But the frequency and execution times will probably be restricted compared to a natively scheduled job.

Arguments

Argument Description Defaut value
param_file Path to the parameters file cron.params
auth_user User login - CLI mode only, if no parameters file is used -
auth_pwd User password - CLI mode only, if no parameters file is used -
verbose if set to 1, more information will be given, use this for troubleshooting. Beware: since the process runs continuously in background, the log files tend to become big pretty quickly. Don't set this options to 1 for a long period of time. 0
status_only (New in iTop 2.0.1) if set to 1, a status about the scheduled tasks is displayed and the process stops immediatly (can be launched in parallel to the normal execution of cron.php). 0

Parameter file

Since the arguments passed to cron.php on the command line are visible to other users on the system, a recommended practice is to move all the sensitive parameters away from the command line. This is the purpose of the “parameter file”.

The argument param_file can be used with most of the REST/CLI web services. By convention, the cron.php service searches for a parameter file name « cron.params » to read its parameters from.

  • A parameter file contains key/value pairs.
  • Comments start with a # (any character found after `#` will be ignored)

The iTop package contains a file named params.distrib that can be used as a template for creating your own parameter file.

Example:

params.txt
# This is a parameter file
#
# If a parameter is given both in the file and in the arguments,
# then the value given as argument is retained
#
 
# Authentication
auth_user = qwertyuiop
auth_pwd = ded!catedL0g1n
 
# My web service
size_min = 20 # Megabytes
time_limit = 40 # Minutes

Make sure that the parameter file is not reachable from the web! Either move it to a directory outside of the web server's scope (for example /etc/itop/ on Linux systems would be a good location) or make a special exclusion rule in your webserver's configuration. Only the process that runs cron.php from the command line should be able to access this file.

Settings

Those settings are configured into the main iTop configuration file: “itop-config.php”

Setting Description Defaut value
cron_max_execution_time Duration (seconds) of the page cron.php, must be shorter than php setting max_execution_time and shorter than the web server response timeout 600
cron_sleep Duration (seconds) before cron.php checks again if something must be done 2
email_asynchronous If set to 1, the emails are sent off line, which requires cron.php to be activated. Exception: some features like the email test utility will force the serialized mode 0

Allowed users

Only administrators are allowed to execute cron.php.

2_2_0/admin/cron.txt · Last modified: 2015/09/23 11:51 (external edit)

";