Actions

Install/3-4/Cron

From Convention Master Documentation

Revision as of 18:59, 4 June 2019 by Silvershock (talk | contribs) (Silvershock moved page Cron Jobs to Install/2-5/Cron: Cron setup should be part of the installation process)

Cron Jobs and CM

CM uses a script (cm_task_manager.php)to run scheduled tasks on the server backend so that it can have more time to do its job, and not require that a user have a tab open in their browser to run. Currently, CM has five scheduled tasks that are run by this script:

Set up Cron Job for CM

In order to take advantage of these scheduled tasks, the cm_task_manager.php script must be called regularly by your server's Cron. Cron allows Linux to run commands or scripts at a given date and time. and schedule scripts to be executed periodically.

NOTE: If we are hosting your installation simply contact support and we will get it setup for you when needed.

These instructions assume:

  1. You have shell access to your web server running Convention Master and sudo privileges. If you don't have either of these and would like help setting this up, please contact our support.
  2. Your server apache user is www-data (default on ubuntu) - if its not, substitute your apache user in "Create entry in Cron".
  3. Your server has the package "run-one" installed. (This comes pre-installed on ubuntu.)
You can check by running dpkg -l run-one in your terminal. This will make sure the script is only ever running one copy at a time and will block any copies from running until the first one is done.

Get You Needed Information

Before you can set up a new Cron task for cm, you should note down where your CM is installed. This is the folder that you downloaded the CM code into. Our install guide has you place it in /var/www/. We will assume this is the location for the rest of the instructions, if your location is different substitute /var/www/ with your path.

Inside this folder you should have automated_tasks/cm_task_manager.php.

This means that the full path of the CM cron script is /var/www/automated_tasks/cm_task_manager.php . Note this as your script path.

Next, you need to get where php is installed. Type which php into your terminal to get this information. It should output something like /usr/bin/php. Note this as your php path.

Last, determine how often you want it to check if there is anything to do. To make up your own you can look at crontabgenerator We recommend every 5 minutes which will look like this */5 * * * *. Note this as your cron timing.

Create entry in Cron

Now you have what you need to create the Cron entry.

  1. Type sudo crontab -u www-data -e to open the Cron file for root user.
  2. Move to the bottom of the file and add a new line.
  3. Enter your cron timing, "run-one", php path, and script path as noted. Your line should look like this: */5 * * * * run-one /usr/bin/php /var/www/automated_tasks/cm_task_manager.php
  4. Make another blank line after your entry and save the file.

Thats it.