Yetiforcecrm: Error Running Cron

Created on 17 May 2019  ยท  10Comments  ยท  Source: YetiForceCompany/YetiForceCRM

Hello, please help. I've tried enabling cron multiple times but could not get it to work.
I'm using Yetiforce 5.1.0
Linux Mint 19.1
PHP Version 7.2.17-0ubuntu0.18.04.1

  • Configuration File (php.ini) Path : /etc/php/7.2/apache2
  • Apache Environment --> PATH : /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • php Variable --> $_SERVER['PATH']: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

When I typed in the terminal whereis php
php: /usr/bin/php7.2 /usr/bin/php /usr/lib/php /etc/php /usr/include/php /usr/share/php7.2-soap /usr/share/php7.2-zip /usr/share/php7.2-intl /usr/share/php7.2-imap /usr/share/php7.2-ldap /usr/share/php7.2-bcmath /usr/share/php7.2-json /usr/share/php7.2-gd /usr/share/php7.2-opcache /usr/share/php7.2-xml /usr/share/php7.2-readline /usr/share/php7.2-common /usr/share/php7.2-curl /usr/share/php7.2-mysql /usr/share/php /usr/share/php7.2-mbstring /usr/share/man/man1/php.1.gz

Hello I'm following the instruction of the link below.
https://yetiforce.com/en/knowledge-base/documentation/administrator-documentation/item/enable-cron

  • Add a file to the crontab:
    So I typed in terminal crontab -e
    */5 * * * * sh /var/www/html/yetiforce/cron/cron.sh > /var/www/html/yetiforce/cache/logs/cron.log 2>&1
    */5 * * * * php /var/www/html/yetiforce/cron.php > /var/www/html/yetiforce/cache/logs/cron.log 2>&1
    */5 * * * * cd /var/www/html/yetiforce; /usr/bin/php7.2 -f cron.php > /var/www/html/yetiforce/cache/logs/cron.log 2>&1

  • Change file permissions /var/www/crm/cron/cron.sh to 775
    chmod -R 775 /var/www/html/yetiforce/cron/cron.sh in terminal

  • Set a path in the file /var/www/crm/cron/cron.sh to PHP
    I opened the file and have the following

#export CRM_ROOT_DIR=`dirname "$0"`/..
#export USE_PHP=php
#export USE_PHP=/usr/local/php53/bin/php
#export USE_PHP=/usr/local/php56/bin/php56

export CRM_ROOT_DIR=/var/www/html/yetiforce/
export USE_PHP=/usr/bin/php7.2

set PHP_EXE=/usr/bin/php7.2

cd $CRM_ROOT_DIR
# TO RUN ALL CORN JOBS
$USE_PHP -f cron.php 

And once restart apache2.service, went back into yetiforce and it still showing not enabled.

Cronlog showing (/var/www/html/yetiforce/cache/logs/cron.log)
bash: */5: No such file or directory

Thank you

โ” question

All 10 comments

@cornutaurus try this path to PHP

export USE_PHP=php7.2

Hi cornutaurus,
my replies inline. Some notes before try a solution.
I'm assuming that

  1. your webserver-root is /var/www/html/
  2. and YF folder name is yetiforce

Hello, please help. I've tried enabling cron multiple times but could not get it to work.
I'm using Yetiforce 5.1.0
Linux Mint 19.1
PHP Version 7.2.17-0ubuntu0.18.04.1

* Configuration File (php.ini) Path : /etc/php/7.2/apache2

* Apache Environment --> PATH : /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

* php Variable --> $_SERVER['PATH']: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

When I typed in the terminal whereis php
php: /usr/bin/php7.2 /usr/bin/php /usr/lib/php /etc/php /usr/include/php /usr/share/php7.2-soap /usr/share/php7.2-zip /usr/share/php7.2-intl /usr/share/php7.2-imap /usr/share/php7.2-ldap /usr/share/php7.2-bcmath /usr/share/php7.2-json /usr/share/php7.2-gd /usr/share/php7.2-opcache /usr/share/php7.2-xml /usr/share/php7.2-readline /usr/share/php7.2-common /usr/share/php7.2-curl /usr/share/php7.2-mysql /usr/share/php /usr/share/php7.2-mbstring /usr/share/man/man1/php.1.gz

Hello I'm following the instruction of the link below.
https://yetiforce.com/en/knowledge-base/documentation/administrator-documentation/item/enable-cron

* Add a file to the crontab:
  So I typed in terminal `crontab -e`
  `*/5 * * * * sh /var/www/html/yetiforce/cron/cron.sh > /var/www/html/yetiforce/cache/logs/cron.log 2>&1`
  `*/5 * * * * php /var/www/html/yetiforce/cron.php > /var/www/html/yetiforce/cache/logs/cron.log 2>&1`
  `*/5 * * * * cd /var/www/html/yetiforce; /usr/bin/php7.2 -f cron.php > /var/www/html/yetiforce/cache/logs/cron.log 2>&1`

What does it mean single quote (`)? Have you wrapped lines between single quotes (`...`)? If yes, please remove both quotes.
YF documentation says: "Add a file to the crontab". You added three files. I suggest to use first one.

*/5 * * * * sh /var/www/html/yetiforce/cron/cron.sh > /var/www/html/yetiforce/cache/logs/cron.log 2>&1
* Change file permissions /var/www/crm/cron/cron.sh to 775
  `chmod -R 775 /var/www/html/yetiforce/cron/cron.sh` in terminal

your command works, but, for single file, the right one is

chmod 775 /var/www/html/yetiforce/cron/cron.sh

-R means recursively.
To check if permissions are correct, please type following cmd in terminal

ls -l /var/www/html/yetiforce/cron/cron.sh

the reply must be something like this

-rwxrwxr-x 1 www-data www-data 719 mar 13 16:30 /var/www/html/yetiforce/cron/cron.sh

-rwxrwxr-x is 775

* Set a path in the file /var/www/crm/cron/cron.sh to PHP
  I opened the file and have the following
#export CRM_ROOT_DIR=`dirname "$0"`/..
#export USE_PHP=php
#export USE_PHP=/usr/local/php53/bin/php
#export USE_PHP=/usr/local/php56/bin/php56

export CRM_ROOT_DIR=/var/www/html/yetiforce/
export USE_PHP=/usr/bin/php7.2

set PHP_EXE=/usr/bin/php7.2

cd $CRM_ROOT_DIR
# TO RUN ALL CORN JOBS
$USE_PHP -f cron.php 

Please restore /var/www/html/yetiforce/cron/cron.sh file content like original

export CRM_ROOT_DIR=`dirname "$0"`/..
export USE_PHP=php
#export USE_PHP=/usr/local/php53/bin/php
#export USE_PHP=/usr/local/php56/bin/php56

cd $CRM_ROOT_DIR
# TO RUN ALL CORN JOBS
$USE_PHP -f cron.php 

And once restart apache2.service, went back into yetiforce and it still showing not enabled.

Cronlog showing (/var/www/html/yetiforce/cache/logs/cron.log)
bash: */5: No such file or directory

Thank you

Summarizing ...
in crontab

*/5 * * * * sh /var/www/html/yetiforce/cron/cron.sh > /var/www/html/yetiforce/cache/logs/cron.log 2>&1

in cron.sh

export CRM_ROOT_DIR=`dirname "$0"`/..
export USE_PHP=php
#export USE_PHP=/usr/local/php53/bin/php
#export USE_PHP=/usr/local/php56/bin/php56

cd $CRM_ROOT_DIR
# TO RUN ALL CORN JOBS
$USE_PHP -f cron.php 

Please try and feedback here

Hello, Thank you vovpff and davide-alghi for your help. I used both of your method and got it to work.

  • nano /etc/crontab

*/5 * * * * sh /var/www/html/yetiforce/cron/cron.sh > /var/www/html/yetiforce/cache/logs/cron.log 2>&1

  • Command

chmod 775 /var/www/html/yetiforce/cron/cron.sh

  • In /var/www/html/yetiforce/cron/cron.sh

export CRM_ROOT_DIR=dirname "$0"/..
export USE_PHP=php7.2

export USE_PHP=php (NOT WORKING)

export USE_PHP=/usr/local/php53/bin/php

export USE_PHP=/usr/local/php56/bin/php56

cd $CRM_ROOT_DIR

TO RUN ALL CORN JOBS

$USE_PHP -f cron.php

restarted cron and it's working now.

Hello I had to reset my computer and tried everything the same and was not able to enable cron.

I'm using Yetiforce 5.1.0
Linux Mint 19.1
PHP Version 7.2.17-0ubuntu0.18.04.1

I tried both crontab -e and sudo crontab -e

*/5 * * * * sh /var/www/html/yetiforce/cron/cron.sh > /var/www/html/yetiforce/cache/logs/cron.log 2>&1

sudo chmod 775 /var/www/html/yetiforce/cron/cron.sh

In cron.sh

export CRM_ROOT_DIR=dirname "$0"/..
export USE_PHP=php7.2

export USE_PHP=php (NOT WORKING)

export USE_PHP=/usr/local/php53/bin/php

export USE_PHP=/usr/local/php56/bin/php56

cd $CRM_ROOT_DIR

TO RUN ALL CORN JOBS

$USE_PHP -f cron.php

I got error on cron.log (only when using sudo crontab -e)
/var/www/html/yetiforce/cron/cron.sh: 11: export: /var/www/html/yetiforce/cron/cron.sh/..: bad variable name

Before it was working and now it did not.

what is in line 11 (/var/www/html/yetiforce/cron/cron.sh) ?
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.

I think you should use the real path of PHP command like /usr/bin/php7.2/php

what is in line 11 (/var/www/html/yetiforce/cron/cron.sh) ?
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.

the line at 11 is
export CRM_ROOT_DIR=dirname "$0"/..

Hello, I reinstall yetiforce and it is working now. Thanks

Here's what worked for me.
Make sure you're running PHP 7.2 or better.
modify your /cron/cron.sh file like this:

export CRM_ROOT_DIR=`dirname "$0"`/..
export USE_PHP=php73
#export USE_PHP=/usr/local/php53/bin/php
#export USE_PHP=/usr/local/php56/bin/php56

cd $CRM_ROOT_DIR
# TO RUN ALL CORN JOBS
$USE_PHP -f cron.php 

set permission to 775
also set /cron.php
to 775 as well

Then I went into Cpanel and entered this:

sh /home/author77/public_html/yeti/cron/cron.sh

make sure your common settings run at least 5 minutes or more.

Your cron should work!!!

(I lived in Warszawa for a year and it was a blast! BTW)
"Zrozumienie tego bylo jak ogladnie czeskiego filmu." :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rubysown picture rubysown  ยท  3Comments

ezbank picture ezbank  ยท  3Comments

scsikid picture scsikid  ยท  3Comments

canomogollon picture canomogollon  ยท  3Comments

ldgbc picture ldgbc  ยท  3Comments