Lunarpages Web Hosting Forum

Web Hosting Guidance and Advice => Web Hosting Help and Troubleshooting => Topic started by: MrPhil on November 28, 2018, 06:32:09 AM

Title: cron jobs
Post by: MrPhil on November 28, 2018, 06:32:09 AM
Is anyone else experiencing problems running cron jobs? I have a couple of cron jobs a day for various site-monitoring and maintenance purposes, and they have not run for a month now. The server is Mizar. Support says they restarted the cron daemon, but still no joy.

All but one are bash scripts or Linux shell commands, and have been running for years (up until a month ago). Do I now require "sudo" or some other magical incantation to run such things? They won't even run as a temporary "run every minute" cron job. (I wish they would implement SSH shell access for everyone, so I don't have to do one-offs as cron jobs.)

The newest script is a PHP program to update my sitemaps. It runs fine via the browser, but doesn't run from cron. I tried "php" as the command, and it tried to run (but MySQLi was lacking -- I suspect PHP is 4.4.9). I changed to "/usr/local/bin/php" but nothing happens now.

I changed the target email from my personal account to an email on my site, in case my ISP was blocking as spam, but no change. This is getting very frustrating. LP must have changed something, but won't admit to anything.

If your site runs cron jobs for various purposes, please check if they are actually being run, and report here if not. I know some systems such as WordPress set up cron jobs for maintenance functions, and those sites will be in trouble if those jobs don't eventually run.
Title: Re: cron jobs
Post by: MrPhil on December 01, 2018, 01:07:48 PM
Things are improving. Support says they fixed some problem with mail being sent from the cron system, and I am starting to get mail from my daily runs. However, I have not been able to find the magical incantation to get a PHP of 5.6 or higher (what runs on the web server). Does anyone know? I can run my new daily PHP job (to update my sitemaps) manually, via the browser, but it would be nice to have cron handle it.
Title: Re: cron jobs
Post by: MrPhil on December 13, 2018, 11:35:12 AM
Well. After much back and forth, and support telling me it worked fine when they tried it, they finally fessed up that old servers like mine (Mizar) are running Jailshell for cron jobs, which means that you can't stray outside your directories, and MySQL is unavailable. I could upgrade to a better server, but I think I'll try waiting for Mizar to be upgraded (including to PHP 7.x) and see if I gain PHP+MySQL capability. In the meantime, I'll have to manually run this job every so often (it's only a sitemap update, so as little as weekly is OK). Site owners who need daily (or more often) cron jobs might want to think about moving servers if their jobs aren't working correctly due to Jailshell.

I asked them to update the cron page to include the information about Jailshell, to simplify matters for other site owners, and avoid a lot of frustration.

Otherwise, cron jobs seem to be working OK now.
Title: Re: cron jobs
Post by: MrPhil on December 14, 2018, 06:45:31 AM
I got another update from support. They said to try cURL:

Code: [Select]
/usr/bin/curl -S -s --user-agent cPanel-Cron https://<domain>/<path>/<file>.php
I just ran a "one off" test on cron and it seemed to work. I'll let you know if tonight's scheduled run fails. Of course, use "http" instead of "https" if needed. If your site redirects (30x) the URL you give, all you'll get is a "redirected to" message, so be sure to give the final URL on the command line.

Note that this is running through the Web server interface. If your PHP script is written to refuse to run from the browser (for security reasons), they say to try

Code: [Select]
/usr/local/bin/ea-php56 /home/<account>/public_html/<path>/<file>.php
I haven't tried it, but that's what they have now on the cron page instructions. Maybe they should update the instructions to show the cURL method, too.