Scheduler

Configure & control the Scheduler

1 Scheduler Cron Job

In order to work correctly the Scheduler needs a crontab entry in /etc/crontab.

/etc/crontab

# Gentics Content.Node Scheduler
* * * * * node /Node/bin/scheduler.sh >> /Node/node/log/scheduler.log 2>&1

2 Scheduler Control API

The API is invoked by using a HTTP GET request


http://[server]/.Node/?do=875&login=[login]&password=[password]&id=[id]&action=[action]

You need to set the following parameters for your request:

Parameter Description
server the domain name or IP address and port of your CMS server
login login of a user with access to the Scheduler Control API
password the user’s password
id the id of the Scheduler job to be modified
action action to be executed on the selected Scheduler job

The id of a Scheduler job can be found by hovering with the mouse over it in the list of Scheduler jobs.

Actions

Action Description
activate will activate the job
deactivate will deactivate the job
run will run the job in the next possible time slot if it is already activated
status will return the status of the Scheduler job. This is the default action in case you provide no action at all
suspend will suspend the Scheduler
resume will resume the Scheduler

2.1 API Response Format

The API will issue a XML response:


<?xml version="1.0"> 
<response>
  <!-- contains a response code -->
  <code>[response code]</code>
  <!-- additional information regarding your request -->
  <message>[message]</message> 
  <!-- id will contain the job id -->
  <job id="[jobid]">
    <!-- see statis information below -->
    <status>[status]</status>
    <!-- the job´s name -->
    <name>[name]</name> 
    <!-- the job´s description -->
    <description>[description]</description> 
    <!-- creator of the job -->
    <creator>[creator]</creator>
    <!-- date the job was created --> 
    <created>[creation date]</created>
    <!-- last editor of the job --> 
    <editor>[editor]</editor> 
    <!-- date the job was changed the last time -->
    <edited>[edit date]</edited> 
    <!-- last run date -->
    <lastrun>[last run]</lastrun> 
    <!-- status of last run -->
    <lastrun_status>[status of last run]</lastrun_status> 
    <!-- duration of last run -->
    <lastrun_duration>[duration of last run]</lastrun_duration> 
    <!-- number of runs so far -->
    <runs>[number of runs]</runs> 
    <!-- average execution time -->
    <average_duration>[average runtime]</average_duration> 
  </job> 
</response> 
2.1.1 Response Codes [response code]
Response Code Description
200 the request was processed successfully
400 invalid parameters
403 invalid permissions
404 could not find Scheduler job with provided id
2.1.2 Status [status]
Value Description
inactive the job is deactivated and currently not running
inactive-running the job has been deactivated, but is currently running
waiting the job is waiting to be executed
running the job is currently running
done the job is planned for a single execution an has run successfully
due the job will run soon, but could not be started, because another job got preference
2.1.3 Lastrun Status [status of last run]

Possible values are OK if the last run was successful, or Failed otherwise.

2.2 Examples

Activating a Scheduler job:


admin@server:~$ curl -i "http://server/.Node/?login=test&password=test&do=875&id=1&action=activate" 
HTTP/1.1 200 OK 
Date: Wed, 04 Feb 2009 12:22:21 GMT 
Server: Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.8e DAV/2 mod_jk/1.2.21 
Set-Cookie: JSESSIONID=deleted; expires=Tue, 05-Feb-2008 12:22:21 GMT; path=/ 
Content-Length: 590 
Content-Type: text/xml 

<?xml version="1.0"> 
<response> 
  <code>200</code> 
  <message>Job 1 was successfully activated.</message> 
  <job id="1"> 
    <status>due</status> 
    <name>Publizierung (laufend)</name> 
    <description></description> 
    <creator>.Node Gentics</creator> 
    <created>2007-02-08 10:05:25</created> 
    <editor>test1 test</editor> 
    <edited>2009-02-04 13:22:22</edited> 
    <lastrun>2009-02-04 13:20:00</lastrun> 
    <lastrun_status>OK</lastrun_status> 
    <lastrun_duration>00:00:08</lastrun_duration> 
    <runs>48364</runs> 
    <average_duration>00:00:05</average_duration> 
  </job> 
</response> 

Suspending the Scheduler


admin@server:~$ curl -i "http://www.server.com/.Node/?login=test1&password=test&do=875&action=suspend"

3 Scheduler E-Mail Notification

In case of errors the Scheduler is able to send notification mails. Use the array $SCHEDULER_JOB_FAILURE_EMAIL to configure notifications.

The Scheduler will send notification emails whenever a shell script that has been executed returns any other exit status than 0.

/Node/etc/node.conf

// receipient address
$SCHEDULER_JOB_FAILURE_EMAIL["to"] = 'admin@emailaddress.com';
// sender address
$SCHEDULER_JOB_FAILURE_EMAIL["from"] = 'root@myserver.com';
// email subject
$SCHEDULER_JOB_FAILURE_EMAIL["subject"] = 'Scheduler Run Failed: #name#';
// email body
$SCHEDULER_JOB_FAILURE_EMAIL["body"] = "Scheduler Run Failed '#name#'
Command: #cmd#
ReturnValue: #returnvalue#
StartTime: #starttime#
EndTime: #endtime#
Output: 
#output#";

In "subject" and "body" the following contents will be replaced with actual data of the scheduler job:

Tag Description
#name# name of the Scheduler task
#cmd# shell command that has been invoked
#returnvalue# return value
#output# output of the shell script
#starttime# time the shell script was started
#endtime# time the shell script finished

4 Scheduler Purge Tasks

Scheduler purge tasks are already available on your system and allow you to execute database maintenance scripts in a regular fashion. This is the basic command for all purge tasks:


. /Node/bin/env.sh; /Node/.node/sh.php do=827 cmd=[command] CONFIGFILE=/Node/etc/node.conf 2>&1

For command one of the following commands may be used:

4.1 purgelogs

Will remove old log entries from the system. The following data will be purged:

  • User activities
  • Error messages and warnings
  • Scheduler task information

The variable $CN_KEEPLOGS allows you to define, when data will be deleted:

/Node/etc/node.conf

// delete logs older than 12 months (default value)
$CN_KEEPLOGS = 12;

4.2 purgeversions

The command purgeversions will delete page versions older than $CN_VERSIONAGE months.

/Node/etc/node.conf

// delete page versions older than 12 months (default value)
$CN_VERSIONAGE = 12;

4.3 purgemessages

The command purgemessages will delete inbox messages older than $KEEP_INBOX_MESSAGES months.

/Node/etc/node.conf

// delete inbox messages older than 12 months (default value)
$KEEP_INBOX_MESSAGES = 12;