yanqzh 发表于 2013-6-20 10:49:59

CebtOS下添加计划任务出错

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

建立了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

licess 发表于 2013-6-20 18:23:59

你哪个php脚本有问题

yanqzh 发表于 2013-6-20 18:27:10

回复 2# 的帖子

php脚本有问题?但是我直接在浏览器上打开URL,又是正常的

licess 发表于 2013-6-20 21:35:04

浏览器可以打开,脚本里直接用curl 访问你那个地址试试

yanqzh 发表于 2013-6-26 08:10:00

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

yanqzh 发表于 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

licess 发表于 2013-6-26 08:27:22

comman not found就是curl没装,装上就行了

yanqzh 发表于 2013-6-26 12:11:42

yum install php-common
yum install php-curl

# 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.

之後
/usr/bin/curl http://xxx.xxxx.org/xxx.php?xxxx
21228
21229
21230
21231
21232
21233
21234
21235
# -bash: 0: command not found

yanqzh 发表于 2013-6-26 12:30:06

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

yanqzh 发表于 2013-6-26 12:55:43

会不会是root没有PHP的执行权限?或者其他权限问题?

licess 发表于 2013-6-26 13:11:22

curl是curl

php-curl是php-curl不是一样的东西,如果让你装php-curl我就和你说装php curl扩展了

yanqzh 发表于 2013-6-26 13:21:38

怎么安装?yum install curl ?

yanqzh 发表于 2013-6-26 13:23:12

回复 11# 的帖子

# 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

yanqzh 发表于 2013-6-27 09:02:51

发现在/usr/bin下,php链接到/usr/local/php/bin/php,所以可以执行php页面,但是仍然无法执行类似"php?xxx"则php后面还有尾巴的页面。
同时在/usr/bin下,curl并没有链接到具体的程序,所以总是显示command not found。

yanqzh 发表于 2013-6-27 09:03:21

回复 14# 的帖子

呼叫军哥,求救解决方法
页: [1] 2
查看完整版本: CebtOS下添加计划任务出错