Install/3-4/Cron: Difference between revisions
From Convention Master Documentation
Silvershock (talk | contribs) m (Silvershock moved page Cron Jobs to Install/2-5/Cron: Cron setup should be part of the installation process) |
mNo edit summary |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
=== | <div style="float:right;"> | ||
[[Install/3-5/CUPS|Next: 3.5 - Install the CUPS Printing System >>]] | |||
</div> | |||
[[Install/3-3/CMConfig|<< Previously: 3.3 - Connect Convention Master to the Database]] | |||
= Set Up Scheduled Tasks = | |||
CM uses a script (<code>cm_task_manager.php</code>)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. | CM uses a script (<code>cm_task_manager.php</code>)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: | Currently, CM has five scheduled tasks that are run by this script: | ||
* See [[Automated Tasks]] | * See [[Automated Tasks]] | ||
== 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 === | === Set up Cron Job for CM === | ||
In order to take advantage of these scheduled tasks, the <code>cm_task_manager.php</code> 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. | |||
In order to take advantage of these scheduled tasks, the <code>cm_task_manager.php</code> 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.''' | '''NOTE: If we are hosting your installation simply contact support and we will get it setup for you when needed.''' | ||
These instructions assume: | These instructions assume: | ||
# You have shell access to your web server running Convention Master and <code>sudo</code> privileges. If you don't have either of these and would like help setting this up, please contact our support. | # You have shell access to your web server running Convention Master and <code>sudo</code> privileges. If you don't have either of these and would like help setting this up, please contact our support. | ||
# Your server | # Your server Apache user is <code>www-data</code> (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. | 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 <code> /var/www/</code>. If your location is different, substitute <code> /var/www/ </code> with your path. | |||
Inside this folder you should have <code>automated_tasks/cm_task_manager.php</code>. | Inside this folder you should have <code>automated_tasks/cm_task_manager.php</code>. | ||
Line 24: | Line 49: | ||
This means that the full path of the CM cron script is <code> /var/www/automated_tasks/cm_task_manager.php </code>. '''Note this as your script path.''' | This means that the full path of the CM cron script is <code> /var/www/automated_tasks/cm_task_manager.php </code>. '''Note this as your script path.''' | ||
Next, you need to | Next, you will need the full path to your PHP executable. Type <code>which php</code> into your terminal to get this information. | ||
It should output something like <code>/usr/bin/php</code>. '''Note this as your php path.''' | It should output something like <code>/usr/bin/php</code>. '''Note this as your php path.''' | ||
Line 30: | Line 55: | ||
We recommend every 5 minutes which will look like this <code>*/5 * * * *</code>. '''Note this as your cron timing.''' | We recommend every 5 minutes which will look like this <code>*/5 * * * *</code>. '''Note this as your cron timing.''' | ||
== Create entry in Cron == | |||
Now you have what you need to create the Cron entry. | Now you have what you need to create the Cron entry. | ||
# Type <code> sudo crontab -u www-data -e</code> to open the Cron file for | # Type <code> sudo crontab -u www-data -e</code> to open the Cron scheduling file (the crontab) for the web user. | ||
# Move to the bottom of the file and add a new line. | # Move to the bottom of the file and add a new line. | ||
# Enter your cron timing | # Enter your cron timing, php path, and script path as noted. Your line should look like this: <code>*/5 * * * * /usr/bin/php /var/www/automated_tasks/cm_task_manager.php</code> | ||
# Make another blank line after your entry and save the file. | # Make another blank line after your entry and save the file. | ||
Setup is now complete. |
Latest revision as of 18:23, 6 October 2023
<< 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:
- See Automated Tasks
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:
- 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. - 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.
- Type
sudo crontab -u www-data -e
to open the Cron scheduling file (the crontab) for the web user. - Move to the bottom of the file and add a new line.
- 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
- Make another blank line after your entry and save the file.
Setup is now complete.