简体   繁体   中英

how can i run cron jobs with PHP?

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!

The cron syntax is basically ok.

Try a...

whereis php

...or...

whereis php5

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

PHP可执行文件将位于/ usr / bin / php中。

Some new server's (2015+), also use /usr/local/bin/php for the php path. so basically /usr/local/bin/php (path of file)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM