User Tools

Site Tools

:: Latest version ::

latest:admin:cron

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
latest:admin:cron [2016/10/10 11:22]
127.0.0.1 external edit
latest:admin:cron [2019/01/09 16:40] (current)
Line 4: Line 4:
  
 The following features rely on the activation of 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 +  ​* **Notification** when a ticket reach a **threshold (TTO/TTR)** will not happen without this web service to be called. (Task://​CheckStopWatchThresholds//​) 
-  * Check ticket SLATickets reaching the limits will be passed into Escalation TTO/TTR states ​+  * Check **ticket SLA**. Tickets reaching the limits will be passed into Escalation TTO/TTR states. 
 +  * Automated Backups. 
 +  * Automatic deletion of useless attachments and in-line images, created during an object creation or edition which was cancelled (Task: //​InlineImageGC//​ which runs hourly) 
 +  ​* Asynchronous emails. By default, this option is disabled. To enable it, set '​email_asynchronous'​ to 1 in the configuration file (Task: //​ExecAsyncTask//​) 
 + 
 +Many Extensions rely on this cron as well, for exemple: Ticket Creation from Email, Approval Automation, Communication to Customers,​...
  
 ===== Scheduling on Windows ===== ===== Scheduling on Windows =====
Line 17: Line 22:
 Edit the crontab to execute the script every 5 minutes: Edit the crontab to execute the script every 5 minutes:
  
-<​code>​ +<​code>​ */5 * * * * www-data ​/​usr/​bin/​php /​var/​www/​html/​itop/​webservices/​cron.php --param_file=/​etc/​itop/​params >>/​var/​log/​itop-cron.log 2>&​1</​code>​
- */5 * * * * root /​usr/​bin/​php /​var/​www/​html/​itop/​webservices/​cron.php --param_file=/​etc/​itop/​params >>/​var/​log/​itop-cron.log 2>&1 +
-</​code>​+
  
 +<note warning>​Do not run ''​cron.php''​ using **root** user!</​note>​
 ===== Scheduling from the web ===== ===== 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 [[https://​www.google.fr/​search?​q=web+cron|web cron]] ​service to run it for you.  But the frequency and execution times will probably be restricted compared to a natively scheduled job.+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 ===== ===== Arguments =====
 ^ Argument^ Description^ Defaut value^ ^ Argument^ Description^ Defaut value^
Line 41: Line 45:
   * Comments start with a # (any character found after `#` will be ignored)   * Comments start with a # (any character found after `#` will be ignored)
  
-<note tip>The iTop package contains a file named params.distrib that can be used as a template for creating your own parameter file.</​note>​+<note tip>The iTop package contains a file named cron.distrib that can be used as a template for creating your own parameter file.</​note>​
  
 Example: Example:
    
-<code sh params.txt>+<code sh cron.params>
 # This is a parameter file # This is a parameter file
 # #
Line 72: Line 76:
 ===== Allowed users ===== ===== Allowed users =====
 Only administrators are allowed to execute ''​cron.php''​. Only administrators are allowed to execute ''​cron.php''​.
 +
 +===== Troubleshooting =====
 +
 +When a task is no more running, there are a few things to know:
 +
 +=== What is the cron.php doing? ===
 +  * The cron.php program, when started, ask for Tasks which implements this php interface, and log them in the table ''​priv_backgroundtask''​.
 +  * The entries present in this table depends on the iTop installed extensions.
 +  * ''​priv_backgroundtask''​ contains multiple information for each **task**, such as:
 +    * when it run for the last time, 
 +    * when is the next run supposed to start,
 +    * what is the average execution time of this task,
 +    * Is the task currently ''​active''​ or ''​paused''​ as requested by an administrator (//field status//)
 +    * ...
 +  * The cron.php program, look for tasks which are active and next run is passed, ​
 +    * execute the tasks **one after the other** asking each task to stop its execution after ''​cron_max_execution_time''​. //The task would of course stops at a point where it makes sense, for example for Mail To Ticket Automation, it could stop between the processing of 2 received Mails.//
 +    * ask the task when should be the next run and store that info in the table,
 +  * Then it checks if it-self was started more than ''​cron_max_execution_time'',​ if yes it commits suicide (//this is because a never ending process usually consumes memory which is not totally freed//)
 +  * else it waits for ''​cron_sleep''​ second before checking the table again for tasks ready to be executed.
 +
 +=== What can be done when... ===
 +
 +__A task seems to never be executed:__
 +
 +When a particular task encounters an issue which make it hangs in an infinite loop, cron.php might be stopped by the php ''​max_execution_time''​ (//usually not when running in CLI//); in all cases the tasks which are following that one will never be executed. In the following run of cron.php, as the tasks are always executed in the same order, the same issue will probably occur again. For identifying the faulty task, you should ''​paused''​ one after the other the tasks which you suspect to have this issue by setting their status in the ''​priv_backgroundtask''​ table and see if you have stopped the faulty one. //Such situation is usually due to a bug of the extension bringing that task, the task facing an unplanned situation.//​
 +
 +The logfile should be monitored to generate alarm to get advanced notice of such issue.
latest/admin/cron.txt · Last modified: 2019/01/09 16:40 (external edit)

";