Actions

Install/3-4/Cron

From Convention Master Documentation

Revision as of 18:23, 6 October 2023 by Alofoxx (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<< Previously: 3.3 - Connect Convention Master to the Database


Set Up Scheduled Tasks

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:

Automated Cron Job setup for CM

Use the this method to install the Cron Job if the following is true:

  • You're running on Ubuntu 18.04 and
  • Have installed Apache and CM with as laid out in this guide
  • The user for apache is www-data

On the command line, navigate to your CM web root (if you followed this guide /var/www), then cd into other/shell_scripts

then run

./addcmcron.sh www-data

and the script will install it for you.

Manual Cron Job Setup for CM

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 scheduler. On Linux, this system is generally Cron, but on your system it may be called something else. 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 (the default on Ubuntu) - if it is something else, substitute your Apache user in "Create entry in Cron".

Fetch Required 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. As with the rest of this guide, we will assume it is located in /var/www/. 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 will need the full path to your PHP executable. 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 scheduling file (the crontab) for the web user.
  2. Move to the bottom of the file and add a new line.
  3. Enter your cron timing, php path, and script path as noted. Your line should look like this: */5 * * * * /usr/bin/php /var/www/automated_tasks/cm_task_manager.php
  4. Make another blank line after your entry and save the file.

Setup is now complete.