Right now my code is:

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

I need to run it as the user "nobody"

If I was at the shell, I'd do su -s /bin/bash nobody first to act as that user.

However, I don't know how to do it inside of the Cpanel CRON jobs... please help!

And to add: The reason I need this is because all of the sudden (after some updates to CentOS) 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

And PHP Functions are not being recognized (like mysql_connect and require_once) I have tried entering the command to be the direct path to PHP, and still no luck.

Of course, if somebody knows how to rectify this problem in the first place, I'll take that as well!

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... Not sure if it was yum update that killed me or what?

link|improve this question

73% accept rate
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
feedback

1 Answer

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.

link|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
show 3 more comments
feedback

Your Answer

 
or
required, but never shown

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