VPS侦探论坛

 找回密码
 注册
查看: 10710|回复: 16

CebtOS下添加计划任务出错

[复制链接]
发表于 2013-6-20 10:49:59 | 显示全部楼层 |阅读模式

呼叫军哥,不懂添加计划任务。总是出错

建立了sh文件,内容如下:
#!/bin/sh
php http://xxx.xxx.com/xxx.php?xxx

执行该sh调试时报错如下:
./xxx.sh: line 2: 0: command not found

========背景======
其实一开始时是直接crontab -e来添加计划任务,但是发现一直没有执行,/var/spool/cron下对应用户的cron文件是已经设置了可执行权限 的。在SSH上直接./root也发现同样错误:line *: 0: command not found
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-6-20 18:23:59 | 显示全部楼层


你哪个php脚本有问题
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-6-20 18:27:10 | 显示全部楼层

回复 2# 的帖子


php脚本有问题?但是我直接在浏览器上打开URL,又是正常的
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-6-20 21:35:04 | 显示全部楼层



浏览器可以打开,脚本里直接用curl 访问你那个地址试试
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-6-26 08:10:00 | 显示全部楼层

用curl执行这个URL也是同样错误。
执行php /home/site/XXX/*.php是成功的,但是尝试将这个URL直接php /home/site/XXX/*.php?xxxx时,又显示出来的是错误,无法执行

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2013-6-26 08:11:24 | 显示全部楼层

/usr/bin/curl http://xxx.xxx.com/*.php?xxxx
这个是无法执行的,或者curl http://xxx.xxx.com/*.php?xxxx也同样无法执行,错误都是comman not found
发表于 2013-6-26 08:27:22 | 显示全部楼层

comman not found就是curl没装,装上就行了
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2013-6-26 12:11:42 | 显示全部楼层

yum install php-common
yum install php-curl

[root@CentOS ~]# yum install php-curl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: centos.ustc.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php53-common.i386 0:5.3.3-13.el5_8 set to be updated
--> Processing Conflict: php53-common conflicts php-common
--> Finished Dependency Resolution
php53-common-5.3.3-13.el5_8.i386 from base has depsolving problems
  --> php53-common conflicts with php-common
Error: php53-common conflicts with php-common
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

之後
[root@CentOS ~]/usr/bin/curl http://xxx.xxxx.org/xxx.php?xxxx
[1] 21228
[2] 21229
[3] 21230
[4] 21231
[5] 21232
[6] 21233
[7] 21234
[8] 21235
[root@CentOS ~]# -bash: 0: command not found
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-6-26 12:30:06 | 显示全部楼层

不知为何,使用wget命令遇到同样的错误:
# /usr/bin/wget -q http://xxx.xxxx.org/xxx.php?xxxx
[1] 23070
[2] 23071
[3] 23072
[4] 23073
[5] 23074
[6] 23075
-bash: 0: command not found
[7] 23076
[8] 23077
[2]   Done                    siteid=22
[3]   Exit 127                0
[4]   Done                    collectname=0
[5]   Done                    startpageid=1
[6]   Done                    maxpagenum=10

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2013-6-26 12:55:43 | 显示全部楼层



会不会是root没有PHP的执行权限?或者其他权限问题?
发表于 2013-6-26 13:11:22 | 显示全部楼层

curl是curl

php-curl是php-curl不是一样的东西,如果让你装php-curl我就和你说装php curl扩展了
 楼主| 发表于 2013-6-26 13:21:38 | 显示全部楼层

怎么安装?yum install curl ?
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-6-26 13:23:12 | 显示全部楼层

回复 11# 的帖子

[root@CentOS ~]# yum install curl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: centos.ustc.edu.cn
Setting up Install Process
Package curl-7.15.5-16.el5_9.i386 already installed and latest version
Nothing to do
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2013-6-27 09:02:51 | 显示全部楼层
发现在/usr/bin下,php链接到/usr/local/php/bin/php,所以可以执行php页面,但是仍然无法执行类似"php?xxx"则php后面还有尾巴的页面。
同时在/usr/bin下,curl并没有链接到具体的程序,所以总是显示command not found。

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2013-6-27 09:03:21 | 显示全部楼层

回复 14# 的帖子

呼叫军哥,求救解决方法
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-24 17:19 , Processed in 0.042766 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表