how can i run cron jobs with PHP?

2019-08-18 21:35发布

I'm running ubuntu 10.04 and have installed php5 via the following:

sudo aptitude install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-imagick php5-mcrypt php5-memcache php5-mhash php5-mysql php5-pspell php5-snmp php5-sqlite php5-xmlrpc php5-xsl

In my research, the following is an example of how to run cron as PHP:

00 * * * * /usr/bin/php /home/john/myscript.php

the problem is... i'm looking in my /usr/bin/ folder... and I do NOT see any PHP folder or symlink... basically /usr/bin/php is non-existant and I need this to run my PHP scripts as cron jobs.

can someone tell me why (after a successful php installation) "/usr/local/bin/php" does not exist? I have check multiple online sources and "/usr/bin/php" should exist by default.

Please help!

3条回答
Explosion°爆炸
2楼-- · 2019-08-18 22:07

Each linux distribution may/will place php in their own location. /usr/local is ment for programs you build yourself, and the distros will generally never put standard packages in there.

Doing a

whereis php

on Ubunto 10.04 tells me it is located in

/usr/bin/php

So you should replace /usr/local/bin/php with that as in:

00 * * * * /usr/bin/php /home/john/myscript.php

You could also ask your distribution package system for a list of files that have been installed by the php5 package. That would reveal where your php binary is installed.

查看更多
Bombasti
3楼-- · 2019-08-18 22:18

The PHP executable will be in /usr/bin/php.

查看更多
Rolldiameter
4楼-- · 2019-08-18 22:26

The cron syntax is basically ok.

Try a...

whereis php

...or...

whereis php5

...to find where your php bin folder is located.

查看更多
登录 后发表回答