LoginLogin  Blog About
Search:

Support » Knowledge Base » Mail »

Setting up a cron job for scheduled mailing

WebAsyst Mail allows specifying a certain time and date for scheduled dispatch of email messages. To make such scheduled emailing work on your server, setting up a so-called cron job is required.

To do so, find out the path to the executable PHP file and the path to the server directory where WebAsyst is installed to access the automatic job launching script in file /kernel/includes/robots/launcher.php. Those paths should be specified as parameters in the following command (in one line):

{path to executable PHP file} launcher.php
{PHP_PATH path to executable PHP file} [GROUP group]

Below is provided a description of the cron job setup on different server types.

Windows

  1. For example, you have the following information:
    • PHP executable file (php.exe) is located in directory C:\php
    • WebAsyst is installed in directory C:\htdocs
    • The mail should be sent out hourly (must be specified in group 1H)
  2. Execute the above mentioned command to create a .bat file (robot.bat). Using the parameters in the above example, the command should have the following form (in one line):
    C:\php\php.exe C:\htdocs\kernel\includes\robots\launcher.php
    PHP_PATH C:\php\php.exe GROUP 1H
  3. In the Windows Start menu choose "Programs -> Accessories -> System Tools", then launch "Scheduled Tasks" and click on "Add Scheduled Task" which will run the Scheduling Tasks Wizard.
  4. Select the program from the list which should be executed at the scheduled time (in our case it is the .bat file created earlier). Enter a name for the newly created task, e.g. "Per Hour Task" and choose how often it will be executed (e.g. "Perform this task - Daily").
  5. Select the time of the first run:

    Start time 0:02
    Perform this task: Every Day
    Start Day: current date
    The value of the Start time parameter in this example means that the mail will be sent out on the second minute of every hour on a daily basis starting with the current day. You will have an option to schedule the mailing function at a shorter time rate as you continue with the Scheduling Tasks Wizard.
  6. Enter the system user name and a his password.
    Note: If you do not enter a password here a scheduled task may not be executed.
  7. To schedule your mail to be sent out with shorter time intervals than daily (e.g. hourly), tick the "Open Advanced Properties for this task when I click finish" option and then click on "Finish". A new window will appear, open the "Schedule" tab and click on "Advanced". Check the "Repeat Task" option and select "Every 1 hours" and "Until Duration 11 hours 30 minutes".
  8. Click on "OK" to complete the task creation.

UNIX/Linux

  1. For example, you have the following information:
    • PHP is installed in directory /usr/local/php
    • WebAsyst is installed in directory /var/www
    • The mail should be sent out hourly (must be specified in group 1H)
  2. Run the crontab command responsible for scheduling commands to be executed periodically:
    crontab -u user -e

    (where user is the name of the system user under which the task is executed). Using the parameters specified in the example, add the following string (in one line):

  3. 2 * * * * /usr/local/php/bin/php /var/www/kernel/includes/robots/launcher.php
    PHP_PATH /usr/local/php/bin/php GROUP 1H

    where 2 * * * * means that the command will be run on the second minute of each hour every day of each month. To schedule the command to be executed on a different minute of each hour, change the first value accordingly. You can read more about the crontab command for Unix-like systems at http://en.wikipedia.org/wiki/Crontab.

  4. Save the file and exit to complete the task creation.
Note: If you are running WebAsyst on a virtual web hosting, you can specify the required settings for mail scheduling in the web hosting control panel (assuming this feature is supported by your web hosting provider). The procedure of setting up a cron job in different control panels may vary but the general idea is to run the following command at certain time intervals (in one line):
{path to executable PHP file} launcher.php
{PHP_PATH path to executable PHP file} [GROUP group]