Using Cron to Run the Task Manager
WebCards includes a task manager that takes care of repetitive tasks such as sending scheduled cards and rebuilding caches. This task manager must be run at regular intervals to ensure that your installation runs smoothly. The most common way of executing this file is to use the crontab (often just referred to as cron). You can read more detail about cron on the Wikipedia website.
The file used by WebCards to send cards is tasks.php. It is located in the base of the root directory. This tutorial will guide you through setting up the cron to execute this file at regular intervals using Cpanel X.
- Find the cron icon in Cpanel
Cron icon in Cpanel X From the main Cpanel page click the “Cron jobs” icon illustrated in the image.
- Choose the standard interface
Cpanel allows you to use the advanced Unix interface to set up cron jobs. However it also provides a more simple interface to help you set it up. This is what we will use. Click the “Standard” button to proceed.
- The main interface – enter your email address
Cron screen in Cpanel X This image shows the main interface for setting up a cron job. At the top you can enter an email address for the output to be sent. You then need to enter a command and then choose how often to run it. First of all enter an email address where you want the results to be sent. You will be informed of how many cards were sent.
- Enter the command to run
Enter the command to run The command we are going to use to execute the file is cURL. You can read more about this command at the manual page. We are also going to use the -s option to make the output nice and remove any error messages. The url to execute is the full url to the file tasks.php
The syntax for cURL is
curl [-options] [URL]
The command that we will use in this example is therefore:
curl -s http://www.mywebcards.net/demo/tasks.php
- Choose when to run the command
Enter the command to run You need to run the command at least once a day but it is recommended that you run it at least a couple of times each day to take account of differences in time zones and in case the command encounters an error. In the example we have set it run four times a day – every six hours. This is a simple setting to use with the cron manager – under hours choose every six hours and leave every other setting how it is.
You should always leave day, month and weekdays as it is unless you have a reason to only send cards on certain days of the week or months of the year.
You can choose to send WebCards more often if you have very high traffic. For example if you wanted to execute the file every minute of every day (not recommended) choose “every minute” under minutes and “every hour” under hours.
Make sure you update your changes in order for them to take effect.
- Email output
Example email output If you enter an email address when setting up the cron job you will receive notifications when the job has been executed. An example is shown in the image on the left.
You will be notified of how many database queries were executed, how many cards were sent and how many cards were unable to be sent.
- Checking send status in the admin centre
Viewing information in the admin centre You can view information about how many WebCards are ready to be sent by looking in the admin centre. The main page of the admin centre lists how many cards are ready to be sent now and how many will be sent in the future.