What are Scheduled Tasks? How to set them?

Some activeCollab modules and functionalities need to be pinged periodically in order to perform their tasks and main purpose. For example, the Invoicing module should be run daily if you wish to automatically create and send invoices configured using the Recurring Profiles feature.

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

  • Frequently - Should be executed frequently. We recommend every 3 minutes, but you can use any value between 1 - 5 minutes.
  • Hourly - Should be executed every hour.
  • Daily - Should be executed every day.

Command examples with exact paths and URL/URLs that need to be triggered are described below.

Scheduled Tasks Troubleshooting

In case that one of the Scheduled Tasks is not triggered on time, you will see a warning about it in the Admin Additional Menu. You can visit Admin > Scheduled Tasks to check the last time that one of these events was triggered and to see which one is malfunctioning

Operations Dependent on Scheduled Tasks #

Various operations depend on Scheduled Tasks. You can find out which operation is triggered by what kind of a Scheduled task here:

Frequently tasks are responsible for:

  • Sending outgoing email notifications for the mailing queue.
  • Importing email messages from defined mailboxes.
  • Sending reminders that are set to be sent at a given date and time.
  • Checking source repositories for new commits.

Hourly Scheduled Tasks take care of:

  • Cleaning up environment cache.
  • Checking source repositories for new commits.

Daily task is used:

  • To send recurring invoices for a given day.
  • Checking source repositories for new commits.
  • Cleaning up various caches and commit daily summaries.

Methods of Triggering Scheduled Tasks #

There are two ways to trigger Scheduled Tasks for your activeCollab:

  1. by triggering a scheduled task URL with a utility such as curl, wget, etc.
  2. by executing a specific PHP file using a PHP command line utility. This method is availbale for IIS server users only.

Of course, both 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 is a little slower because the web server is added to the mix. In general, it is completely up to you which method you will be using, the end results will be the same.

Trigger Tasks with cron (Linux, BSD, etc) #

To trigger Scheduled Tasks, you will have to set up scheduling software to execute task scripts or to ping specific activeCollab URLs at defined time.

For example, on UNIX you can use curl to achieve this. You should use curl to request specific URLs to trigger events. activeCollab Scheduled Tasks are invoked by the web server. Here are the commands that you will need to set in the crontab file:

1
2
3
4
*/3       *      *       *       *       /usr/bin/curl -s -L "http://url/of/frequently?code=XyZty" > /dev/null
0         *      *       *       *       /usr/bin/curl -s -L "http://url/of/hourly?code=XyZty" > /dev/null
0        12      *       *       *       /usr/bin/curl -s -L "http://url/of/daily?code=XyZty" > /dev/null
0         7      *       *       *       /usr/bin/curl -s -L "http://url/of/paper?code=XyZty" > /dev/null

*"XyZty" - first five characters of your license key

Save the changes. This will "tell" the server to execute task files:

  • Every 3 minutes for frequently tasks.
  • On an hourly script on 0 minute of every hour.
  • On a daily script every day at noon.
  • On a daily script that triggers sending Morning Paper email.

Trigger Tasks with Scheduled Tasks (Windows) #

On Windows server you can also use Scheduled Tasks to trigger 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 achieve that, open the command line and type in the following commands:

1
2
3
4
schtasks /create /ru "IIS" /sc minute /mo 3 /tn "activeCollab frequently job" /tr "C:\php\php.exe C:\activecollab\tasks\frequently.php -f"
schtasks /create /ru "IIS" /sc hourly /st 12:00:00 /tn "activeCollab hourly job" /tr "C:\php\php.exe C:\activecollab\tasks\hourly.php -f"
schtasks /create /ru "IIS" /sc daily /st 12:00:00 /tn "activeCollab daily job" /tr "C:\php\php.exe C:\activecollab\tasks\daily.php -f"
schtasks /create /ru "IIS" /sc daily /st 07:00:00 /tn "activeCollab paper job" /tr "C:\php\php.exe C:\activecollab\tasks\paper.php -f"

Important Details for This Setup

  • Use the real path to your php.exe file.
  • Use exact paths to frequently.php, daily.php and hourly.php files, as found on the Administration > Scheduled Tasks page.
  • If you have white spaces in you paths to php.exe or activecollab folder you need to add \" to escape it. For example, cases like this:
1
schtasks /create /ru "webserver_user" /sc minute /mo 3 /tn "activeCollab frequently job" /tr "C:\Program Files (x86)\php\php.exe C:\activecollab\tasks\frequently.php -f"

could be avoided by using:

1
schtasks /create /ru "webserver_user" /sc minute /mo 3 /tn "activeCollab frequently job" /tr "\"C:\Program Files (x86)\php\php.exe\" C:\activecollab\tasks\frequently.php -f

Trigger Tasks with launchd (Mac OS X) #

On Mac OS 10.4 or later, Apple recommends that you use launchd instead of cron, xinetd, mach_init, and init. Scheduled Tasks are defined as XML files that will instruct 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 Scheduled Task URLs:

  • com.a51.activeCollabFrequently.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?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>-L</string>
        <string>http://url/of/frequently?code=XyZty</string>
    </array>
    <key>StandardOutPath</key>
    <string>/dev/null</string>
    <key>StandardErrorPath</key>
    <string>/tmp/ac_schedule_err.log</string>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>180</integer>
</dict>
</plist>

  • com.a51.activeCollabHourly.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?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>-L</string>
        <string>http://url/of/hourly?code=XyZty</string>
    </array>
    <key>StandardOutPath</key>
    <string>/dev/null</string>
    <key>StandardErrorPath</key>
    <string>/tmp/ac_schedule_err.log</string>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
</dict>
</plist>

  • com.a51.activeCollabDaily.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?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>-L</string>
        <string>http://url/of/daily?code=XyZty</string>
    </array>
    <key>StandardOutPath</key>
    <string>/dev/null</string>
    <key>StandardErrorPath</key>
    <string>/tmp/ac_schedule_err.log</string>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>12</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
</dict>
</plist>
  • com.a51.activeCollabPaper.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?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.activeCollabPaper</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/curl</string>
        <string>-s</string>
        <string>-L</string>
        <string>http://url/of/paper?code=XyZty</string>
    </array>
    <key>StandardOutPath</key>
    <string>/dev/null</string>
    <key>StandardErrorPath</key>
    <string>/tmp/ac_schedule_err.log</string>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>7</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
</dict>
</plist>