Some activeCollab modules need to be run periodically in order to perform their tasks and functionality. For instance, the Backup module should be run daily if you wish to create daily backups.

All of these events are executed by periodically making a web request on specific activeCollab URL/URLs or executing specific PHP files through command lines (check this article for details). There are three time periods which activeCollab supports:

  1. frequently - Should be executed frequently. We recommend every 3 minutes, but you can use any value between 1 - 5 minutes.
  2. hourly - Should be executed every hour.
  3. daily - Should be executed every day.

Command examples with exact paths and URL/URLs that need to be triggered are available on the Administration > Scheduled Tasks page:

Note

activeCollab has three different waysfor generating URLs. Because of that, URLs in your system may look a bit different to the URLs displayed in a screenshot or used in other examples.

Scheduled Tasks page in Administration is also used to check when was the last time these events were triggered, so it's useful for troubleshooting actions that are executed on events triggered by scheduled tasks.

1. Methods of Triggering Tasks

Scheduled tasks in activeCollab can be triggered in two ways:

  1. by triggering a task URL with a utility such as curl, wget, etc.
  2. by executing a specific PHP file using a PHP command line utility

Both of these approaches have advantages and disadvantages. For example, using PHP to trigger files skips the web server and the overhead that it adds, but you will need to have the PHP command line utility configured on your server. On the other hand, triggering a URL always works when activeCollab is properly configured, but it's a little slower because the web server is added to the mix.

Examples:

/usr/bin/curl -s "http://url/of/hourly/task" > /dev/null
/usr/bin/php "/path/to/activecollab/tasks/hourly.php" > /dev/null

The exact commands you need to execute are listed on the Administration > Scheduled Tasks page of your activeCollab installation.

2. Direct Access Protection

Scheduled Task URLs can be protected from direct visits by adding the first five letters of your license key as a code parameter:

http://example.com/collab/public/index.php?path_info=frequently&code=QGNig

Protection is automatically turned on for all new installations since activeCollab 2.1. If you upgraded from a version older than 2.1 to the latest version, please add the following code to your config/config.php file in order to enable it:

define("PROTECT_SCHEDULED_TASKS", true);

Note that you'll need to update your cron configuration once you have done so because this changes the URLs that need to be pinged.

3. Trigger Tasks with cron (Linux, BSD etc)

In order for events to work you'll need to set-up some kind of scheduling software to execute task scripts or ping specific activeCollab URLs at specific times.

For example, on UNIX you can use cron and PHP or curl to achieve this. Open crontab for editing by executing:

crontab -e

in your command line. Then insert the following text into the field:

*/3       *      *       *       *       php "/path/to/activecollab/tasks/frequently.php" > /dev/null
0         *      *       *       *       php "/path/to/activecollab/tasks/hourly.php" > /dev/null
0        12      *       *       *       php "/path/to/activecollab/tasks/daily.php" > /dev/null

and save it. This will tell PHP to execute task files:

  1. Every 3 minutes for frequently tasks.
  2. On an hourly script on 0 minute of every hour.
  3. On a daily script every day at noon.

If the PHP command line interface is not available on your server, you can use curl to request specific URLs to trigger events. activeCollab behaves the same way as task files, but instead of using a PHP command line utility, tasks are invoked by the web server. Here are the commands that you'll need to set in the crontab file:

*/3       *      *       *       *       /usr/bin/curl -s "http://url/of/frequently/task" > /dev/null
0         *      *       *       *       /usr/bin/curl -s "http://url/of/hourly/task" > /dev/null
0        12      *       *       *       /usr/bin/curl -s "http://url/of/daily/task" > /dev/null

4. Trigger Tasks with Scheduled Tasks (Windows)

On Windows you can also use Scheduled Tasks to trigger scheduled tasks in activeCollab. To set-up Scheduled Tasks on Windows XP, Vista and Windows 7 (as well as Windows 2003 Server or later) you can use schtasks.exe. To do so, open the command line and type in the following commands:

schtasks /create /ru "System" /sc minute /mo 3 /tn "activeCollab frequently job" /tr "C:\php\php.exe C:\activecollab\tasks\frequently.php -f"
schtasks /create /ru "System" /sc hourly /st 12:00:00 /tn "activeCollab hourly job" /tr "C:\php\php.exe C:\activecollab\tasks\hourly.php -f"
schtasks /create /ru "System" /sc daily /st 12:00:00 /tn "activeCollab daily job" /tr "C:\php\php.exe C:\activecollab\tasks\daily.php -f"
Note
  1. Use the real path to your php.exe file.
  2. Use exact paths to frequently.php, daily.php and hourly.php files, as found on the Administration > Scheduled Tasks page.

5. Trigger Tasks with launchd (Mac OS X)

On Mac OS 10.4 Tiger or later, Apple recommends that you use launchd instead of cron, xinetd, mach_init, and init. Tasks are defined as XML files that tell launchd what to do and when.

To define the three scheduled tasks that activeCollab requires, please create the following files in the /Library/LaunchAgents folder and make sure that you set the correct task URLs (you can find them on the Administration > Scheduled Tasks page of your activeCollab setup):

1. com.a51.activeCollabFrequently.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.a51.activeCollabFrequently</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/curl</string>
        <string>-s</string>
        <string>"http://activecollab.dev/public/index.php?path_info=frequently&amp;code=CODE"</string>
        <string> &gt;</string>
        <string>/dev/null</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StartInterval</key>
    <integer>180</integer>
</dict>
</plist>

2. com.a51.activeCollabHourly.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.a51.activeCollabHourly</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/curl</string>
        <string>-s</string>
        <string>"http://activecollab.dev/public/index.php?path_info=hourly&amp;code=CODE"</string>
        <string> &gt;</string>
        <string>/dev/null</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
</dict>
</plist>

3. com.a51.activeCollabDaily.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.a51.activeCollabDaily</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/curl</string>
        <string>-s</string>
        <string>"http://activecollab.dev/public/index.php?path_info=daily&amp;code=CODE"</string>
        <string> &gt;</string>
        <string>/dev/null</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>12</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
</dict>
</plist>

These settings will define following tasks:

  1. A frequently task that fires every 3 minutes;
  2. An hourly task that fires at first minute of every hour;
  3. A daily task that fires every day at noon (the server's time, not activeCollab's).

To see if everything is working properly, periodically check the Administration > Scheduled Tasks page to check the last time tasks were executed successfully.

6. Modules Dependent on Scheduled Tasks

The following modules are dependent on Scheduled Tasks:

  1. System module - Requires an hourly event to clean-up the cache;
  2. Backup module - Requires a daily event to create daily backups;
  3. Incoming Mail module - Requires a frequently event to check POP3 and IMAP mailboxes. A daily event is also used to clean-up old activity logs;
  4. Source module - Requires a frequently task to check repositories for new revisions and read revision information
Note

This list applies to activeCollab 2.3. Custom modules may require any of the three events triggered by Scheduled Tasks to work properly.