Enable cron

Cron is a Unix daemon that triggers other programs periodically. It uses crontabs to save information about cron tasks that will be enabled. It is recommended to use it in Linux, but if the same file will be added to the scheduler in Windows, it will also work. In practice, YetiForce can perform certain tasks automatically with cron and trigger them in the background. 

2021-02-14_21-11-55.png

The start of cron can be enabled in a few simple steps: 

  1. Linux system:
    • Add a file to the crontab, e.g. in such format (path-to-crm is the full absolute path to the CRM folder, eg. /var/www/),
      it is important that the script is run with the same privileges as the owner of the CRM files:
      • */2 * * * * www-data /path-to-crm/cron/cron.sh > /path-to-crm/cache/logs/cron.log 2>&1
      • */2 * * * * www-data sh /var/www/cron/cron.sh > /var/www/cache/logs/cron.log 2>&1
      • */2 * * * * sh /path-to-crm/cron/cron.sh > /path-to-crm/cache/logs/cron.log 2>&1 [pay attention to a correct path to the YetiForce system],
      • */2 * * * * php /path-to-crm/cron.php > /path-to-crm/cache/logs/cron.log 2>&1
      • */2 * * * * cd /path-to-crm; /usr/local/bin/php -f cron.php > /path-to-crm/cache/logs/cron.log 2>&1
    • Change file permissions /var/www/crm/cron/cron.sh to 744 [or to other permissions that are compatible with an internal security policy in a company]. 
      2021-02-13_22-34-00.png
    • Set a path in the file /var/www/crm/cron/cron.sh to PHP: export USE_PHP=/usr/local/php74/bin/php74 [here it is also required to pay attention to the file, because it can be located differently on each server and also keep an eye on a path to PHP that is different for various servers. An administrator can provide information about this path or it can be checked in phpinfo]. 
      2021-02-15_10-19-09.png
    • Pay attention to the end of line because it should be Unix (LF). If it is Windows on Linux servers, it may cause errors and the system won't be able to run the SH file. 
      2021-02-15_10-22-18.png
  2. Windows system - it is not recommended to use Windows as a server for YetiForce.
  3. URL can be used to run cron, e.g. https://gitdeveloper.yetiforce.com/cron.php?app_key=xxxx where app_key is the key that is located in the config/Main.php file in the $application_unique_key variable.
    application_unique_key.png
  4. If there is a problem with triggering cron from CLI, there is an alternative, but it is not recommended:
  • Thursday, 10 August 2017