11. Tasks.php Explained
AS OF HELPSPOT 5.0 TASKS.PHP IS NO LONGER USED
See documentation here on the new cron jobs and and queuing system
What does tasks.php do?
The tasks.php script has 3 main functions in HelpSpot:
- Check email accounts and convert emails into requests
- Send out reminders
- Delete requests marked as trash
Running tasks.php on a regular basis is critical to using HelpSpot. Major functionality will not work properly without this script running.
Where is it located?
The tasks.php file is in the root HelpSpot folder. The same one which contains admin.php and index.php.
How often should tasks.php run?
Every 1-5 minutes, however every 1-2 is recommended.
How do I run the script?
On Linux/Unix the script should be run via Cron. On Windows Scheduled Tasks should be used. Windows users note that if you've installed using our Windows Installer a scheduled task has already been setup for you.
Configuration for Windows:
If you've used the HelpSpot Windows Installer this has already been done for you.
Configuration for Linux/Unix/OSX:
tasks.php can be called directly through PHP on the command line or via an HTTP call. Several examples are below, but be sure to replace the generic paths with the ones for your installation:
Direct command line method for every minute (preferred):
* * * * * /usr/bin/php /path/to/helpspot/tasks.php
Using HTTP with curl:
* * * * * curl http://www.domain.com/tasks.php
Tips and Tricks
You can manually run the tasks.php file in your browser to force it to pull in email (and it's other actions). This is often useful for testing purposes. Just visit the script in your browser at http://www.domain.com/tasks.php. Note that it is normal for the output to be a blank white screen.
If you're having problems with an email account it can be useful to turn on tasks.php debugging in Admin->Settings->Email Integration. Once this is on if you visit the tasks.php file in your browser (as described above) you'll see debugging output. It's often useful to do "view source" in your browser to see the output in a nicer format.
If you want to prevent people from outside being able to access tasks.php via HTTP you can set the IP's that are allowed to call it in Admin->Settings->System.
Check just one mailbox
Normally each time tasks.php is run it checks all mailboxes you've configured in Admin->Mailboxes. If you'd like to run mailboxes on their own checking schedules though it's possible to have HelpSpot only check one mailbox when tasks.php is run. To do so you need to pass in the ID of the mailbox which you can find in Admin->Mailboxes.
If you were using the HTTP method you would change the URL to:
If you were using the command line method you would do this:
* * * * * /usr/bin/php /path/to/helpspot/tasks.php --id=4
New in HelpSpot version 4: Check multiple mailboxes
Customers with many Email Mailboxes (or a few which usually contain large attachments) may want to divide mailboxes out to separate scheduled tasks. This allows you to stagger when they are called, or to separate email mailbox checking to multiple PHP calls. This reduces the change of hitting an error due to meeting memory limits while checking for new email.
For example, if you have 6 Email Mailboxes (of id 1, 2, 3, 4, 5, and 6) configured and want to check 3 at a time, you can create two tasks.
If you were using the HTTP method you would make 2 separate calls like so:
If you were using the command line method you make 2 separate crontasks like so:
* * * * * /usr/bin/php /path/to/helpspot/tasks.php --id=1,2,3 * * * * * /usr/bin/php /path/to/helpspot/tasks.php --id=4,5,6