GoDaddy PHP Cron Job (shared server)

I recently wrote about writing a (PHP) Cron Job on Host Gator.  Now I had to do one for GoDaddy.  I’m on a shared server (not sure if that makes a difference?).

I’m using CPanel with PHP version 7.1… and at the time of writing, GoDaddy’s documentation only has CPanel for a lower PHP version.  I called tech support, but they only pointed me in the right direction…

Here’s the right syntax:

/usr/bin/php-cli /home/<username>/public_html/<site>/file.php

I reluctantly turned on sending emails; good thing I did, because I found out there was an error.

BIG GOTCHA: you can’t have a period in the directory name; as in, if you’re working in “/username/public_html/yoursite.com/cronjob.php” that won’t work – it doesn’t like the “yoursite.com” part.  Remove that so it’s just “/username/public_html/yoursitecom/cronjob.php” (or some variation that doesn’t have the period).  The script wasn’t even running, and I didn’t realize this until I turned on the email notifications.

Once I did turn on the notifications, I was getting this error:

Failed loading /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so:  /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so: cannot open shared object file: No such file or directory

Failed loading /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ZendGuardLoader.so:  /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ZendGuardLoader.so: cannot open shared object file: No such file or directory
Content-type: text/html; charset=UTF-8

Thanks to Stack Overflow – https://stackoverflow.com/questions/40109716/cronjob-not-starting-in-godaddy-shared-hosting) for pointing out that you need the “-cli” in the command to avoid that error.

UPDATE: there’s another “gotcha” in GoDaddy’s PHP Cron Job usage; I wrote about it here.

By the way: if you thought this blog post was helpful, check out the book I wrote on PHP, geared toward intermediate web developers.

No
Comments

Comments are now closed.