[英]how can i run cron jobs with PHP?
I'm running ubuntu 10.04 and have installed php5 via the following:我正在运行 ubuntu 10.04 并通过以下方式安装了 php5:
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:在我的研究中,以下是如何将 cron 作为 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.问题是......我正在查看我的 /usr/bin/ 文件夹......我没有看到任何 PHP 文件夹或符号链接......基本上 /usr/bin/php 是不存在的,我需要这个将我的 PHP 脚本作为 cron 作业运行。
can someone tell me why (after a successful php installation) "/usr/local/bin/php" does not exist?有人能告诉我为什么(在成功安装 php 之后)“/usr/local/bin/php”不存在? I have check multiple online sources and "/usr/bin/php" should exist by default.
我检查了多个在线资源,默认情况下“/usr/bin/php”应该存在。
Please help!请帮忙!
The cron syntax is basically ok. cron语法基本上可以。
Try a... 试试...
whereis php
...or... ...要么...
whereis php5
...to find where your php bin folder is located. ...以查找您的php bin文件夹所在的位置。
PHP可执行文件将位于/ usr / bin / php中。
Some new server's (2015+), also use /usr/local/bin/php
for the php path.一些新服务器(2015+),也使用
/usr/local/bin/php
作为 php 路径。 so basically /usr/local/bin/php (path of file)
所以基本上
/usr/local/bin/php (path of file)
Each linux distribution may/will place php in their own location. 每个Linux发行版都可能/将php放在自己的位置。 /usr/local is ment for programs you build yourself, and the distros will generally never put standard packages in there.
/ usr / local是您自己构建的程序的目录,发行版通常不会在其中放置标准软件包。
Doing a 做一个
whereis php
on Ubunto 10.04 tells me it is located in 在Ubunto 10.04上告诉我它位于
/usr/bin/php
So you should replace /usr/local/bin/php with that as in: 因此,您应该将/ usr / local / bin / php替换为:
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. 您还可以向您的分发软件包系统询问php5软件包已安装的文件列表。 That would reveal where your php binary is installed.
那将揭示您的php二进制文件安装在哪里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.