Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 1: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 2:02
    
Does it work when manually running from command line? –  quanta Aug 23 '11 at 2: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 2:12
    
@Shackrock: We ask questions as questions to learn, not in comments. –  womble Aug 23 '11 at 2:32

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
Sorry, new to linux commands, can you tell me how to dump the results to a temp file? –  Shackrock Aug 23 '11 at 2: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 2:24
    
not sure what this tells me though... Root: pastebin.com/Sk2AZn2Z nobody: pastebin.com/QHNBFAu2 –  Shackrock Aug 23 '11 at 2:28
    
Run the same commands in cron job as I suggested and compare with the above result. –  quanta Aug 23 '11 at 2: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 2:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.