CMS  Version 3.9
index.inc
Go to the documentation of this file.
1 <h2>Scheduled Tasks</h2>
2 <p>Web applications sometimes have periodic housekeeping tasks that need to be run in
3 the background without user intervention, such as sending out email digests, reindexing
4 SOLR search indexes, or other maintenance activities. The Scheduled Tasks component provides
5 this functionality.</p>
6 <p>Your server will need some configuration to be able to run scheduled tasks. On a UNIX
7 style machine, this involves adding a worker script into crontab. The steps for setting up
8 such a script are as follows:</p>
9 <ol>
10  <li>First you need to create a secure authentication token that can be used to log in
11  your scheduled task worker. To do this, go to <b>User Manager > Authentication Tokens</b>
12  and create a token with the <b>User</b> configured to a user with sufficient permissions to
13  run the scheduled workers (usually <em>admin</em>), <b>Enabled</b> checked and <b>Redirect on Success</b>
14  set to <tt>/action/scheduled_task/run_tasks</tt>. For extra security you can add the local IP
15  address for you server to restrict the token to local access only. You can set the token name
16  directly, or a secure randomized token name can be generated for you.</li>
17  <li>First create the script and configure it to be run hourly. For most modern UNIX style
18  systems this involves creating file in <tt>/etc/cron.hourly</tt>. A simple example script
19  for the site <tt>my.fakoli.org</tt> is shown below (you would replace the <tt>my.fakoli.org</tt>
20  hostname and the token with the values for your own server):
21  <pre>
22 #!/bin/bash
23 
24 wget -O /dev/null -a /srv/www/logs/my.fakoli.org.tasks.log http://my.fakoli.org/action/auto_login/authenticate?token=MYSECURETOKEN
25  </pre>
26  If your server is running under SSL (recommended) you need to use a slightly different script:
27 <pre>
28 #!/bin/bash
29 
30 wget -O /dev/null --no-check-certificate -a /srv/www/logs/my.fakoli.org.tasks.log https://my.fakoli.org/action/auto_login/authenticate?token=MYSECURETOKEN
31  </pre>
32  </li>
33  <li>Save the script and make it executable by running the command <tt>chmod a+x <i>{script name}</i></tt>
34  </li>
35 </ol>
36 <p><em>N.B. Depending on your server set up, you will need to be logged in as a root user or sudoed in order
37 to complete the above operations.</em></p>
38 <p>Once the script is in place it will be called once an hour at the time offset specified in your <tt>/etc/crontab</tt> file.
39 You can test the configuration by enabling the <b>Scheduled Task: Validate Configuration</b> task. This will send a verification
40 message to a chosen email address every time it is triggered. You can configure the email address this is sent to via the <b>Scheduled Tasks</b>
41 tab in <b>Site Configuration > Application Setting</b>.
42 </p>
$helpTree style
Definition: tree.inc:46
$form action
Definition: edit.inc:67
Definition: site.inc:40
$forumRequest to
read only
Definition: edit.inc:62
$email message