I have spent about two weeks on and off trying to figure this out. I have honestly tried so many different things and configurations, I don't remember all of them anymore. Essentially I can't get the Magento CronJobs to function correctly.
I have no experience with Cron Jobs until now, so there has been a steep learning curve so far. I have Bluehost for a hosting company with a shared server, so no direct command line root access as far as I know, just Cpanel. After going back and forth with the hosting company and trying different methods, this at least seems to be correctly launching the Magento CronJobs. */5 * * * * /bin/sh /MyDomainUserName/public_html/cron.sh
I spent a long time trying to work with AoeScheduler but couldn't ever get it to successfully produce a heartbeat task and all jobs always stayed pending. I gave up on it and got Cron Doctor for now.
The tasks sort of work... they launch and I get through a couple and then it gets "stuck" - so far every time on "Captcha Delete Expired Images".
Once this happens, I get an email from Cron Daemon saying "Status 500 Internal Server Error Content type: text/html" every 5 minutes. And in my error_log I get this: "-Jan-2016 00:10:02] PHP Parse error: syntax error, unexpected T_FUNCTION in /MyDomainSpecifics/public_html/app/code/core/Mage/Core/Helper/Abstract.php on line 240"
Once I use Cron Doctor to delete all of the Magento jobs, it goes around to the next 5 minutes and I get a clean Cron Daemon email that just says "Content type: text/html" - with no new errors in error_log, and the jobs start running again, same ones, and then repeats getting stuck like above.
I have tried leaving the "Magento Cron (Scheduled Tasks) - all the times are in minutes" - on the default settings of 15,20,15,10,60,600 and I have tried settings recommended in other posts like 60,1,60,120,120,120 and 15,60,60, 120, 120, 3000.
I really feel like I don't have a handle on this and don't know what to do at this point. I have always been able to figure out how to do something, one way or another.... but I am lost on this. I feel like I have gotten closer, but being close, doesn't do me any good.
I'm pretty sure that the 500 error is because the jobs back up, to many in index or whatever... but I don't know how to fix this.
I have also used PHPadmin to go in and clear the cron_schedule directly, among about a million other solutions I have tried. None solving my problem. I may come back and edit this as I think of other things I have tried, or post them as a response. I just want to get this up and get any input I can.
Any and all help would be GREATLY appreciated!!
edit... I also already edited my Cron.php file to add the line$isShellDisabled = true; AFTER the line $isShellDisabled = (stripos(PHP_OS, 'win') === false) ? $isShellDisabled : true;
Another avenue I explored was the time zone issue some mentioned. My server is on USA/MDT and we are USA/EST although I couldn't think of anywhere to really apply this knowledge since I have cronjob running every 5 minutes and not at a specific time. I did change the php.ini file line: date.timezone = "America/Denver"; to date.timezone = "America/New_York";
****EDIT/UPDATE**** I spoke again with Bluehost customer support and inquired about the PHP environment that Cron is running in. Below is the most important parts of our conversation... I am not sure how to directly apply this to the Magento Crons, any help would really be appreciated.
BlueHost: Notice: Be aware that this only modifies your ~/public_html/php.ini file. If you apply these changes, please confirm that your other php.ini files are up-to-date for the appropriate version of PHP you're using. We highly suggest using the "Single php.ini" option for your desired version of PHP, to ensure that the proper php.ini is being applied for your site's software. If you choose to use PHP 5.4, you'll want to make sure your crons use "/usr/php/54/usr/bin/php" instead, as otherwise it will use PHP 5.2.
Me: How would I implement this specifically for my issue?
Bluehost: Well, basically to implement that you would just replace any instances of the php command in your cron with /usr/php/54/usr/bin/php instead, so that it runs that command using php 5.4. That said, we don't provide any technical support for crons beyond confirming that you're running.
Me: I am running a .sh file from my cronjobs - which then directly runs the php file within the server environment. wouldn't this already by default be 5.4?
Bluehost: No, it would be 5.2, unless the sh file also includes rules to run it as 5.4
I'm not sure if you tried this solution yet but if you haven't, feel free to give it a try.
Open up the cron.php file in your Magento root directory (usually "public_html") and look for the following line of codes:-
$isShellDisabled = (stripos(PHP_OS, ‘win’) === false) ? $isShellDisabled : true;
Add the following codes in a new line exactly after the above line of codes:-
$isShellDisabled = true;
Thank you for the reply, unfortunately I have already done that. It was one of those many solutions I tried. I will edit my post to add that in as something I have already done.
ok, so, I have a temporary solution but it's not what I wanted. I can change my CronJobs command from Cpanel to access cron.php as long as I use this preface /usr/php/54/usr/bin/php - however everything I read said I should be running the Magento Crons through Cron.sh and not Cron.php directly. I'm not sure how I can do that. The other answer was right in that for some reason Bluehost runs it's crons by default in PHP 5.2 but they only offer PHP5.4 and PHP5.6 for the server environment. This make no sense to me.
Is there a command I can add to the cron.sh file to get it to call cron.php via the command /usr/php/54/usr/bin/php ?
I thought there was something in cron.sh that double checked to make sure a job wasn't already running or something like that before it ran cron.php
I am facing same issue like
when cron task comes to this point , all task get stopped since this task get never complete. Did u solve the issue? Please help. Thanks.
Specifying the php.ini File
To specify an alternate php.ini file, you'll need to use the -c flag in your PHP command line.
In this instance, /home/username/public_html/php.ini is the full path to the php.ini file you'd like to use and/home/username/public_html/myscript.php is the full path to the php script you'd like to run. Using your actual username, change the path to the php.ini and the file you intend to run accordingly
Note: Your home directory may be home1, home2, home3, etc.