-1

Right now my call in the CPanel CRON job section is:

nice php /home/user/public_html/process.php 

After the latest updates to CentOS and PHP 5.2, I now am receiving this error on all CRON jobs:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0

To make matters worse, PHP Functions are not being recognized (like mysql_connect and require_once) (only in CRON scripts though from CPanel, the normal publically accessible PHP files are loading to the public internet without a problem).

From some googling, it looks like I need to run it as the user "nobody" in order for it to work correctly.

If I was at the shell, I'd do su -s /bin/bash nobody first to act as that user, but in CPanel CRON scripts, that is not working.

UPDATE: All errors of php process file when ran from CRON, as requested:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: require_once(../users/config/application_top.php): failed to open stream: No such file or directory in /home/username/process.php on line 34

Fatal error: require_once(): Failed opening required '../users/config/application_top.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/username/process.php on line 34

The files noted inside require_once() are indeed there, so I have no idea why it's saying this. And, it's worked for months already... I have to assume it was the yum update that killed this.

Shackrock
  • 198
  • 5
  • 16
  • Don't run things as nobody, don't have files owned as nobody, don't do anything as nobody. As far as your broken PHP install, you fix it by reverting the broken package updates. – womble Aug 23 '11 at 01:00
  • @womble So, care to tell me why I can't run things as nobody, or own things as nobody? Serverfault is a learning platform last I checked, just would like something constructive here... – Shackrock Aug 23 '11 at 02:02
  • Does it work when manually running from command line? – quanta Aug 23 '11 at 02:04
  • @quanta yes, it does. This is what ive been doing once a day to run the jobs actually until i can fix this... – Shackrock Aug 23 '11 at 02:12
  • @Shackrock: We ask questions as questions to learn, not in comments. – womble Aug 23 '11 at 02:32
  • This question appears to be off-topic because it is about [`working with a service provider's management interface, such as cPanel`](http://serverfault.com/help/on-topic). – HopelessN00b Jan 13 '15 at 22:12

1 Answers1

1

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0

Make sure that you have the same:

  1. $PATH
  2. all other environment variables

when running in cron job. You can dump the echo $PATH and env output to a temp file and compare with result when running from the command line.

quanta
  • 50,327
  • 19
  • 152
  • 213
  • Sorry, new to linux commands, can you tell me how to dump the results to a temp file? – Shackrock Aug 23 '11 at 02:22
  • Put the below commands into your cron job: `echo $PATH > /tmp/path.out` and `env > /tmp/env.out`. Moreover, you should redirect all the errors to a log file with: `php /home/user/public_html/process.php > /tmp/process.log 2>&1` to see what it say. – quanta Aug 23 '11 at 02:24
  • not sure what this tells me though... Root: http://pastebin.com/Sk2AZn2Z nobody: http://pastebin.com/QHNBFAu2 – Shackrock Aug 23 '11 at 02:28
  • Run the same commands in cron job as I suggested and compare with the above result. – quanta Aug 23 '11 at 02:32
  • `echo $PATH` returns something very different, but I don't know why: `/usr/bin:/bin` --- and by doing `env` I see that the user is not `nobody`, it's actually my `username` (not really a problem I guess). But, how can I fix the path, at the least? – Shackrock Aug 23 '11 at 02:39
  • Insert a line `export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin` before running your php script. – quanta Aug 23 '11 at 02:42
  • at the top of every php file, before ` – Shackrock Aug 23 '11 at 02:43
  • @Shackrock let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/1160/discussion-between-quanta-and-shackrock) – quanta Aug 23 '11 at 02:46
  • circling back to this old question. It turned out that the yum update had installed another version of PHP. So for whatever reason, I was now running two different PHP versions, and the CRON scripts were not finding PHP successfully. I wish I could report back the exact fix, but I hired the host to fix this problem. Thanks – Shackrock Mar 19 '13 at 12:06