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

I have nginx and php-fpm installed on my Centos vps box. I need to add a cronjob to execute a script every 10 minutes. I tried crontab -e with the following in it:

*/10 * * * * /path/to/script/script.php

However, it's not executing properly. It says there is errors in the php code and there isn't

--

Error when attempting to install php-cli

--> Running transaction check
---> Package php-cli.i386 0:5.1.6-27.el5_5.3 set to be updated
--> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-cli
--> Finished Dependency Resolution
php-cli-5.1.6-27.el5_5.3.i386 from base has depsolving problems
  --> Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-cli-5.1.6-27.el5_5.3.i386 (base)
Error: Missing Dependency: php-common = 5.1.6-27.el5_5.3 is needed by package php-cli-5.1.6-27.el5_5.3.i386 (base)
share|improve this question
    
Please include the error messages your receiving. –  David Aug 25 '11 at 19:50
    
It says there's something with the first line. This is the first line: define("IN_MYBB", 1); –  Spencer Aug 25 '11 at 19:53

3 Answers 3

up vote 1 down vote accepted

php-fpm is fastcgi only.. install the php-cli package also

edit

You have to enable the repo to install

yum -y --enablerepo=webtatic install php-cli
share|improve this answer
    
I updated your post with the errors it gives when when trying to install php-cli. –  Spencer Aug 25 '11 at 22:12
    
i don't see an update –  Mike Aug 26 '11 at 2:10
    
I updated my post instead...I guess it won't let me edit your post. –  Spencer Aug 26 '11 at 2:24
    
how did you install php-fpm? –  Mike Aug 26 '11 at 3:42
    

Without seeing the errors it's hard to know, but I'd say it's one of:

  • The script is executable but missing #!/usr/bin/php at the beginning.
  • The script has #!/usr/bin/php but is not executeable.
  • The script is not executable and doesn't have #!/usr/bin/php so crond doesn't know how to properly handle it.

If you change your cron to:

*/10 * * * * /usr/bin/php /path/to/script/script.php

Does it work?

share|improve this answer
2  
/usr/bin/php doesn't exist...I have php-fpm installed. –  Spencer Aug 25 '11 at 20:05

I had the same problem with the same configuration. For whatever reason, after installing php-fpm months ago, I just now noticed PHP wasn't in the path. The php-cli script couldn't find php, I couldn't find php, phpinfo() didn't help, where was it? Essentially, installing "php-cli" put php back in the path. All my websites were running fine but my php-cli script stopped working because php was gone, I just didn't notice till last night.

The solution that worked for me:

Step 1

yum install php-cli

====================================================================================================================== Package Arch Version
Repository Size ====================================================================================================================== Installing: php-cli x86_64
5.4.13-1.el6.remi remi 2.6 M Updating for dependencies: php-common x86_64
5.4.13-1.el6.remi remi 891 k php-fpm x86_64 5.4.13-1.el6.remi remi 1.3 M php-mysql x86_64
5.4.13-1.el6.remi remi 134 k php-pdo x86_64 5.4.13-1.el6.remi remi 117 k

Transaction Summary ====================================================================================================================== Install 1 Package(s) Upgrade 4 Package(s)

Total download size: 5.0 M Is this ok [y/N]: y

Hopefully this upgrade doesn't break anything.

Note: I had to add "Remi" repository to get php-fpm. I really thought php-cli was already installed because this PHP script had been working for months. The script stopped working around the time I switched to php-fpm.

Step 2

Removed #!whatever from first line of script.

php -l myscript.php

"No syntax errors detected in myscript.php"

Woot!

Step 3

Updated my crontab with "-f" parameter:

43 * * * * someuser php -f /home/getposts/myscript.php

Works!

share|improve this answer

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.