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:
Command examples with exact paths and URL/URLs that need to be triggered are available on the Administration > Scheduled Tasks page:
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.
Scheduled tasks in activeCollab can be triggered in two ways:
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.
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.
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:
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
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"
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&code=CODE"</string>
<string> ></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&code=CODE"</string>
<string> ></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&code=CODE"</string>
<string> ></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:
To see if everything is working properly, periodically check the Administration > Scheduled Tasks page to check the last time tasks were executed successfully.
The following modules are dependent on Scheduled Tasks:
This list applies to activeCollab 2.3. Custom modules may require any of the three events triggered by Scheduled Tasks to work properly.