Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Hi,

I have a problem getting my cron jobs to run. I have searched this forum for the answer and also googled it and tried all the suggestions there.

Basically I have a couple of php files that need to be run via cron. These files run correctly if I enter the following in the url:

https://www.mysite.com/myscript.php

When I try to create them in Cron Jobs they do not execute. So far I have tried:

/usr/bin/php /home/mysite/public_html/myscript.php

/usr/bin/php -f /home/mysite/public_html/myscript.php

/usr/bin/php -q /home/mysite/public_html/myscript.php

https://www.mysite.com/myscript.php

php -f /home/mysite/public_html/myscript.php


None of them seem to work. Could it be that I need to enable something somewhere on WHM Easyapache to get them to work?

Any advice would be greatly appreciated

Kind regards
 

Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Hi,

thanks for answering. Unfortunately that doesn't work either.

May I ask, what does the file permission need to be with a cron job? I have tried 644, 744 but still no effect.

I have read the cpanel help on cron jobs and there is only one example (which didn't work for me). I wondered if the actual cron job needs to be enabled somewhere in the server settings?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
When I try to create them in Cron Jobs they do not execute. So far I have tried:

/usr/bin/php /home/mysite/public_html/myscript.php

/usr/bin/php -f /home/mysite/public_html/myscript.php

/usr/bin/php -q /home/mysite/public_html/myscript.php

https://www.mysite.com/myscript.php

php -f /home/mysite/public_html/myscript.php
Hello @Sunlander,

Please try using the following command for the cron job:

Code:
/usr/local/bin/php /home/mysite/public_html/myscript.php
The /usr/local/bin/php binary calls the PHP command-line handler.

Thank you.
 

Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Hi Michael,

apologies for delay responding. I have just tried your suggestion and it doesn't like that either.

I don't understand what might be preventing it from running. Like I said in my original post it runs perfectly if I do it from the url, which is why I wondered if it may be a server setting?
 

rpvw

Well-Known Member
Jul 18, 2013
1,100
477
113
UK
cPanel Access Level
Root Administrator
Couple of things that you could try:

The domain specific call detailed in the following post might work if you are using ea4 cPanel MultiPHP Manager
Hello,

You should use one of the following commands for PHP with your cron jobs:

General example:

Code:
/usr/local/bin/php /home/$user/public_html/path/to/cron/script
Domain-specific example:

Code:
/usr/local/bin/ea-php56 /home/$user/domain_path/path/to/cron/script
In the above example, replace “ea-php56” with the PHP version assigned to the domain you wish to use. Look in the MultiPHP Manager for the actual PHP version assigned to a domain.

Thank you.
If you are using Cloiulinux alt-php with PHP Selector, you could try constructing the call with something like
Code:
/opt/alt/php72/usr/bin/php -q /home/mysite/public_html/myscript.php
(Change the php version to the one you are using on the domain)

Hope something works for you :)
 

Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Hi,

I have ea4 and just tried your suggestions as follows:

/usr/local/bin/ea-php72 /home/$user/public_html/script.php

May I ask, should it say $user as I put above (I copied from your example) or should it be my proper root username? I did try the other but it still didn't run.
 

rpvw

Well-Known Member
Jul 18, 2013
1,100
477
113
UK
cPanel Access Level
Root Administrator
The php version should be changed to whatever the domain is set to use, and the /$user/ changed to the actual username that is in the path to the script.

If nothing works, it might be worth checking if the php you are using has the cli module installed (you should ask your web host if you don't have root access) it is conceivable that the web host has chosen not to install it.
 
Last edited:
  • Like
Reactions: cPanelMichael

Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Hi,

still cannot get it to work. I have root access (I am on php 72) and checked via easyapache that cli is installed for this and it is. I noticed there were other cli related modules that were unchecked - are all of those with cli in the title meant to be enabled do you know?

I don't know if there is any test to check that cpanel is firing the cron jobs automatically? Or whether I can add the cron job to run using ssh - if that has more chance of working.

At a bit of a loss with this now regarding what else to try
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
I don't know if there is any test to check that cpanel is firing the cron jobs automatically?
Hello,

Yes, you can review the following log file to confirm the cron job is executing:

/var/log/cron

Can you let us know the entry the full entry that appears for the account? Also, if it's not running, make sure the crond service is not stopped:

Code:
/scripts/restartsrv_crond
Thank you.
 

Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Hi, the sites I am trying to run the crons on are mysite1 and mysite3 - this is the output from the code you gave me. it is script.php I am trying to run

Code:
Jun  3 03:09:04 541267 run-parts(/etc/cron.daily)[5783]: finished logrotate
Jun  3 03:09:04 541267 run-parts(/etc/cron.daily)[5717]: starting makewhatis.cron
Jun  3 03:09:08 541267 run-parts(/etc/cron.daily)[5996]: finished makewhatis.cron
Jun  3 03:09:08 541267 run-parts(/etc/cron.daily)[5717]: starting mlocate.cron
Jun  3 03:10:01 541267 CROND[6088]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/script.php)
Jun  3 03:10:01 541267 CROND[6081]: (mysite2) CMD (/usr/bin/wget -O /dev/null "https://www.mysite3.com/index.php?option=com_community&task=cr$
Jun  3 03:10:01 541267 CROND[6090]: (mysite2) CMD (/usr/bin/php /home/mysite2/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:10:01 541267 CROND[6082]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/components/com_osproperty/cron.php)
Jun  3 03:10:01 541267 CROND[6085]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/components/com_osproperty/importIMG.php)
Jun  3 03:10:01 541267 CROND[6084]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/components/com_osproperty/cronxml.php)
Jun  3 03:10:01 541267 CROND[6086]: (root) CMD (/usr/local/cpanel/scripts/dcpumon-wrapper >/dev/null 2>&1)
Jun  3 03:10:01 541267 CROND[6089]: (root) CMD (/usr/bin/test -e /etc/cpanel-dovecot-solrdisable || /usr/local/cpanel/3rdparty/scripts/cpanel_d$
Jun  3 03:10:01 541267 CROND[6091]: (mysite3) CMD (/usr/local/bin/php /home/mysite3/public_html/script.php)
Jun  3 03:10:01 541267 CROND[6092]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jun  3 03:10:01 541267 CROND[6083]: (mysite2) CMD (/usr/bin/php /home/mysite2/public_html/components/com_osproperty/cron.php)
Jun  3 03:10:01 541267 CROND[6087]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:11:01 541267 CROND[6233]: (mysite2) CMD (/usr/bin/php /home/mysite2/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:11:01 541267 CROND[6232]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:12:01 541267 CROND[6273]: (mysite2) CMD (/usr/bin/php /home/mysite2/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:12:01 541267 CROND[6272]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:13:01 541267 CROND[6308]: (mysite2) CMD (/usr/bin/php /home/mysite2/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:13:01 541267 CROND[6307]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:14:01 541267 CROND[6343]: (mysite2) CMD (/usr/bin/php /home/mysite2/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:14:01 541267 CROND[6344]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:15:01 541267 CROND[6430]: (mysite3) CMD (/usr/local/bin/php /home/mysite3/public_html/script.php)
Jun  3 03:15:01 541267 CROND[6431]: (mysite2) CMD (/usr/bin/php /home/mysite2/public_html/components/com_osproperty/cron.php)
Jun  3 03:15:01 541267 CROND[6432]: (mysite4) CMD (/usr/bin/php -f /home/mysite4/public_html/brookestone/cron/vtigercron.php)
Jun  3 03:15:01 541267 CROND[6436]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:15:01 541267 CROND[6435]: (mysite2) CMD (/usr/bin/wget -O /dev/null "https://mysite3.com/index.php?option=com_easyblog&task=cronfee$
Jun  3 03:15:01 541267 CROND[6441]: (mysite3) CMD (/usr/bin/wget -O /dev/null "https://www.mysite3.com.au/index.php?option=com_community&$
Jun  3 03:15:01 541267 CROND[6443]: (mysite4) CMD (/usr/bin/php -f /home/mysite4/public_html/crm/cron/vtigercron.php)
Jun  3 03:15:01 541267 CROND[6439]: (mysite4) CMD (/usr/bin/php -f /home/mysite4/public_html/brookestone/public_html/cron.php)
Jun  3 03:15:01 541267 CROND[6434]: (mysite3) CMD (/usr/bin/wget -O /dev/null "https://mysite3.com.au/index.php?option=com_easyblog&task=$
Jun  3 03:15:01 541267 CROND[6446]: (mysite3) CMD (/usr/bin/php -f /home/mysite3/public_html/crm2/cron/vtigercron.php)
Jun  3 03:15:01 541267 CROND[6437]: (mysite2) CMD (/usr/bin/wget -O /dev/null "https://www.mysite3.com/index.php?option=com_community&task=cr$
Jun  3 03:15:01 541267 CROND[6440]: (mysite2) CMD (/usr/bin/php -f /home/mysite2/public_html/components/com_osproperty/cronxml.php)
Jun  3 03:15:01 541267 CROND[6447]: (mysite5e) CMD (/usr/bin/php -f /home/mysite5e/public_html/crm/cron/vtigercron.php)
Jun  3 03:15:01 541267 CROND[6445]: (mysite3) CMD (/usr/bin/php -f /home/mysite3/public_html/components/com_osproperty/cronxml.php)
Jun  3 03:15:01 541267 CROND[6433]: (mysite3) CMD (https://www.mysite3.com.au/index.php?option=com_komento&task=clearCaptcha)
Jun  3 03:15:01 541267 CROND[6449]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/components/com_osproperty/cronxml.php)
Jun  3 03:15:01 541267 CROND[6442]: (mysite2) CMD (/usr/bin/php /home/mysite2/public_html/templates/jreviews_overrides/sendalert.php)
Jun  3 03:15:01 541267 CROND[6450]: (mysite4) CMD (/usr/bin/php -f /home/mysite4/public_html/new/public_html/cron.php)
Jun  3 03:15:01 541267 CROND[6451]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/components/com_osproperty/importIMG.php)
Jun  3 03:15:01 541267 CROND[6453]: (cscloudsolutions) CMD (/usr/bin/php -f /home/cscloudsolutions/public_html/crm/cron/vtigercron.php)
Jun  3 03:15:01 541267 CROND[6438]: (mysite3) CMD (/usr/bin/php -f /home/mysite3/public_html/components/com_osproperty/importIMG.php)
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @Sunlander,

The output shows the cron jobs are executing. You mentioned testing the PHP files via a web browser. Can you also try running the cron job command while logged in via SSH as the account username? This should help to narrow down the cause of the issue.

Thank you.
 

Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Hi, I didn't realise there were pages of those. Below are the last ones. May I ask, do I run the cron as it is in the cron job i.e. like this:

nano usr/bin/php /home/mysite1/public_html/script.php ?


Code:
Jun  7 15:05:01 541267 CROND[3329]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/components/com_osproperty/cronxml.php)
Jun  7 15:05:01 541267 CROND[3330]: (mysite1) CMD (/usr/bin/php /home/mysite1/public_html/script.php)
Jun  7 15:05:01 541267 CROND[3328]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/components/com_osproperty/importIMG.php)
:05:01 541267 CROND[3332]: (ltscom) CMD (/usr/bin/wget -O /dev/null "https://www.mysite3.com/index.php?option=com_community&task=cr$
Jun  7 15:05:01 541267 CROND[3336]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/components/com_osproperty/cron.php)
Jun  7 15:05:01 541267 CROND[3338]: (mysite3) CMD (/usr/bin/php -f /home/mysite3/public_html/script.php)
Jun  7 15:05:01 541267 CROND[3343]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  7 15:05:01 541267 CROND[3344]: (root) CMD (/usr/local/cpanel/scripts/eximstats_spam_check 2>&1)
Jun  7 15:05:01 541267 CROND[3340]: (root) CMD (/usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1)
Jun  7 15:05:01 541267 CROND[3342]: (root) CMD (/usr/local/cpanel/scripts/dcpumon-wrapper >/dev/null 2>&1)
Jun  7 15:07:01 541267 CROND[3494]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  7 15:08:01 541267 CROND[3615]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  7 15:09:01 541267 CROND[3656]: (root) CMD (/usr/local/cpanel/scripts/clean_user_php_sessions > /dev/null 2>&1)
Jun  7 15:09:01 541267 CROND[3659]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  7 15:10:01 541267 CROND[3773]: (mysite1) CMD (/usr/bin/php /home/mysite1/public_html/script.php)
Jun  7 15:10:01 541267 CROND[3771]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/components/com_osproperty/cronxml.php)
Jun  7 15:10:01 541267 CROND[3770]: (ltscom) CMD (/usr/bin/wget -O /dev/null "https://www.mysite3.com/index.php?option=com_community&task=cr$
Jun  7 15:10:01 541267 CROND[3772]: (mysite1) CMD (/usr/bin/php -f /home/mysite1/public_html/components/com_osproperty/importIMG.php)
Jun  7 15:10:01 541267 CROND[3774]: (root) CMD (/usr/bin/test -e /etc/cpanel-dovecot-solrdisable || /usr/local/cpanel/3rdparty/scripts/cpanel_d$
Jun  7 15:10:01 541267 CROND[3776]: (ltscom) CMD (/usr/bin/php /home/ltscom/public_html/templates/jreviews_overrides/sendalert.php)
Jun  7 15:10:01 541267 CROND[3775]: (root) CMD (/usr/local/cpanel/scripts/dcpumon-wrapper >/dev/null 2>&1)
Jun  7 15:10:01 541267 CROND[3780]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/components/com_osproperty/cron.php)
Jun  7 15:10:01 541267 CROND[3782]: (mysite3) CMD (/usr/bin/php -f /home/mysite3/public_html/script.php)
Jun  7 15:10:01 541267 CROND[3783]: (mysite3) CMD (/usr/bin/php /home/mysite3/public_html/templates/jreviews_overrides/sendalert.php)
Jun  7 15:10:01 541267 CROND[3781]: (root) CMD (/usr/lib64/sa/sa1 1 1)
 
Last edited by a moderator:

rpvw

Well-Known Member
Jul 18, 2013
1,100
477
113
UK
cPanel Access Level
Root Administrator
I would guess the problem is
^@^@^@^@^@^@^@^@EasyApache PHP config file not found: %s
^@^@^@^@^@^@^@Default PHP not defined in EasyApache configuration file
^@^@^@^@^@^@^@Configured PHP version %s does not have a CGI binary installed, using default PHP version
^@^@^@^@^@^@Default PHP version %s does not have a CGI binary installed, exiting
^@^@^@ea-php-cli Copyright 2017 cPanel, Inc.
^@php_cli unable to execute php :%d: (%d) :%s
Either your EA4 build is missing the relevant cli modules, or the EA config itself needs repairing.
 

Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Hi,
when I log in to SSH I see a message saying:

*************************************************************
************************ WARNING ****************************
*************************************************************
Your server is currently being configured for cPanel.
The cPanel installation changes a number of system files, and
for this reason it is NOT RECOMMENDED that you use your
server during this time.
We'll send you an email when cPanel is installed and your
server is ready to go!
Best Wishes,
The cPanel installer

Could that be part of the problem? How do I repair EA4?

Also when I am in the server I see this message:

You must reboot the server to apply kernel updates.

I am afraid to click this in case it deletes or damages my files.

In EasyApache when I search for CLI these are the settings in attached image upload. Are there other things I need to install for this to work? Do I need to install CGI?
 

Attachments

Last edited by a moderator:

rpvw

Well-Known Member
Jul 18, 2013
1,100
477
113
UK
cPanel Access Level
Root Administrator
It rather looks like you have bigger problems that are way above my pay grade ........... over to Michael :-D
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Below are the last ones. May I ask, do I run the cron as it is in the cron job i.e. like this:

nano usr/bin/php /home/mysite1/public_html/script.php ?
Hello @Sunlander,

You used the wrong command. "Nano" is a text editor. You'd run the same command that you enter when adding the cron job. EX:

Code:
/usr/bin/php /home/mysite1/public_html/script.php
Thank you.
 

Sunlander

Well-Known Member
May 7, 2018
68
4
58
UK
cPanel Access Level
Root Administrator
Ah ...

I just ran it without nano this is what it shows:

Code:
# /usr/bin/php /home/mysite1/public_html/script.php
Content-type: text/html; charset=UTF-8
<html>
 <head>
<script
  src="/media/jui/js/jquery.js"></script>
 <script>
function run(){
        var files = {"media\/reaxml\/read\/QT39271014_AREXTEST_LRex-Blackburnewe                                               bsite-2086_TS20180524003218.xml":"rental","media\/reaxml\/read\/QT39271014_AREXT                                               EST_LRex-Blackburnewebsite-2086_TS20180525003219.xml":"rental","media\/reaxml\/r                                               ead\/test2.xml":"rental"};
        if(typeof files==='object'){
                var fileArray =[];
                for(key in files){
                                //fileArray[key.toString()] = files[key].toStrin                                               g();
                                /* var data = {
                                'file' : key +'='+ files[key],
                                'fun':'createStandardFormat'
                                }; */
                                var data = new FormData();
                                 data.append('file',key +'='+ files[key] );
                                 data.append('fun','createStandardFormat' );
                                var oReq = new XMLHttpRequest();
                                oReq.addEventListener('load',reqListener);
                                oReq.open('POST','script.php');
                                oReq.send(data);
                                function reqListener(){
                                        console.log('request successfully execut                                               ed');
                                }
                                  /* jQuery.ajax({
                                        url:'script.php',
                                        type:'POST',
                                        data:data,
                                        success : function (res){
                                                //JSON.parse(res);
                                                console.log(res);
                                        }
                                });  */
                                //break;
                }
        }else{
                console.log(files);
                var p = document.createElement("p");
                                var msg = document.createTextNode("No files to i                                               mport");
                p.appendChild(msg);
                var el = document.getElementById('msg');
                if(typeof el !== 'undefined')
                        el.appendChild(p);
        }
}
</script>
  <script>
   run();  </script>
 </head>
 <body>
        <div class="msg" id="msg">
                </div>
 </body>
</html>
[root@541267 ~]#
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @Sunlander,

It looks like the PHP script was successfully executed. Can you confirm that it performed the specific action you needed it to (whatever the script is supposed to do as part of the cron job)?

Thank you.