Web Hosting Forum | Lunarpages

Author Topic: Path to PHP5 on Thetis for CRON  (Read 8572 times)

Offline thefeldkircher

  • Space Explorer
  • ***
  • Posts: 6
Path to PHP5 on Thetis for CRON
« on: December 12, 2014, 04:34:42 AM »
Hi All

I am trying to get a CRON job to run a php5 script, I need it for PHP PDO.

I have tried the following paths but they fail:

/usr/local/cpanel/bin/jailshell: /usr/local/php5/bin/php: No such file or directory
/usr/local/cpanel/bin/jailshell: /usr/local/php5/bin/php-cgi: No such file or directory

Any help would be appreciated

Thanks
thefeldkircher

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6230
Re: Path to PHP5 on Thetis for CRON
« Reply #1 on: December 12, 2014, 07:33:43 AM »
If your server's default PHP is 5.x, have you tried just "php"? If "php" isn't found, or is version 4.x (which I doubt is even installed any more on Lunarpages), you'll have to look for PHP5. Note that any shell command line is not guaranteed to use the same PHP as a server web page. If you have a command line available (SSH), or just use a one-time cron job, run find / -name "php*" -print 2>/dev/null to find all the php commands.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline thefeldkircher

  • Space Explorer
  • ***
  • Posts: 6
Re: Path to PHP5 on Thetis for CRON
« Reply #2 on: December 12, 2014, 11:35:31 AM »
Thanks for your help, but this returned find: `/': Permission denied

I'm whereis php see if that can shed soon light

OK, I can now connect to php and get the script to run. However the PHP version must be pre php5 because it doesn't recognise PDO.

<b>Fatal error</b>:  Class 'PDO' not found in <b>/home/uname/public_html/.................

But the site works in the browser....

cPanel states PHP 5.3.28

Bizarre
« Last Edit: December 12, 2014, 12:01:07 PM by thefeldkircher »

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6230
Re: Path to PHP5 on Thetis for CRON
« Reply #3 on: December 12, 2014, 01:21:11 PM »
If the server is using 5.3, I'm a bit surprised that the command-line version isn't close to that. However, anything's possible. I'm also surprised that the "find" command failed -- I've used that exact command many times. This is a Linux OS server, and not Windows?

Have you verified that your code is including whatever file is needed (if any) to create class PDO? If so, could there be a path problem and you're having it look in the wrong place? I'm wondering, because the error message seems to say it's looking for the class definition in one of your files, not a system file.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline thefeldkircher

  • Space Explorer
  • ***
  • Posts: 6
Re: Path to PHP5 on Thetis for CRON
« Reply #4 on: December 13, 2014, 05:13:28 AM »
Thanks for your help.

I've given up on cron, it wont do what I want.

So I'm looking at mySQL Events Scheduler instead, maybe this is closer to what I need.

Thanks again.

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6230
Re: Path to PHP5 on Thetis for CRON
« Reply #5 on: December 13, 2014, 07:15:35 AM »
Remember that when running from a command line (such as when using cron), you can't count on anything being the same as when using a server. You need to explicitly specify all paths and environment variables/settings, as they may not be the same as when using the server.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline thefeldkircher

  • Space Explorer
  • ***
  • Posts: 6
Re: Path to PHP5 on Thetis for CRON
« Reply #6 on: December 13, 2014, 03:36:52 PM »
OK I'm back.

It seems you need 'SPECIAL' Privileges to run Events, which I understand are not provided in shared hosting accts.

So I'm having another crack at cron.

Previously I tried running my script with PDO, this seems to be not visible by cron, I think php.ini for cron is not enabled and I cant' (obviously ) edit php.ini in cPanel.

So I've made a retro-grade step and I'm now trying mysql_connect (Old School Shit), this also fails, for god knows why reason.

The error reported:
mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I am getting seriously pissed-off with this crap, all I want to do is automate a db table to be restored to its original content once a day.
It seems this is an impossible task at the moment.

I've now raised a ticket with LP, hopefully they can resolve this annoying problem and I can get back to doing something more productive.

Thanks again for your assistance
« Last Edit: December 14, 2014, 04:15:34 AM by thefeldkircher »

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6230
Re: Path to PHP5 on Thetis for CRON
« Reply #7 on: December 14, 2014, 09:19:49 AM »
I think php.ini for cron is not enabled
That's quite possible. If so, you would have to modify the PHP code to set anything needed (ini_set?) from within your script.

Quote
I cant' (obviously ) edit php.ini in cPanel.
What? Yes you can make your own php.ini on LP servers, when using the Apache server. You just need to add a suPHP_ConfigPath statement to .htaccess to get PHP to look in the right place (and be sure to use a phpinfo() script to test that it's working). Since the command line shell isn't reading .htaccess, that is probably useless to you in this situation.

Quote
So I've made a retro-grade step and I'm now trying mysql_connect (Old School Shit), this also fails, for god knows why reason.

The error reported:
mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
I think I've seen that error reported before, but I don't recall the solution. Be sure to search this forum for that error message. It's possible that the solution given won't work from the command line, but it's worth checking.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline thefeldkircher

  • Space Explorer
  • ***
  • Posts: 6
Re: Path to PHP5 on Thetis for CRON
« Reply #8 on: December 15, 2014, 10:57:46 AM »
Hi

Still waiting for LP to solve the CRON/PDO issue, but I did eventually get the dinosaur mysql_connect to work.

I changed 'localhost to '127.0.0.1' in my db_server value, just in case anybody was wondering.

I am now able to run cron to update my db once a day, but this seems clunky and retrograde. oh um, It will suffice for now.

Best Regards

Offline mithcd

  • Intergalactic Superstar
  • *****
  • Posts: 131
Re: Path to PHP5 on Thetis for CRON
« Reply #9 on: December 20, 2014, 07:40:28 AM »
Or you can set your host file to point localhost to 127.0.0.1.

 

Share |