日期:2014-05-16  浏览次数:20729 次

shell手机可以执行,自动执行不了,万里长征,我就差这最后一步了!
各位,我的SHELL脚本如下,动可以执行,数据也已经导入到数据库中了,放到crontab中日志是写进去了,就是里面的数据没有导入到数据库中,shell已经改成了CHMOD -R 777了,请问各位老大帮我分析下原因,万里长征,我就差这最后一步了

#!/bin/bash
source ~/.bash_profile
#清空数据
datetime=`date +%Y%m%d`
datetime2=`date +%Y%m%d`
datetime3=`date +%T`
echo '=======================开始于'$datetime2 $datetime3'=======================' >>/www/wanleke/ftpshell/datainput.log
cd /www/wanleke/back/
#数据导入
host="localhost"  
user="wanleke_admin"  
passwd="123456"
dbname="wanleke_fun" 
mysql -u$user -p$passwd -h$host $dbname < wlk_uploadfile_20130416.sql

datetime2=`date +%Y%m%d`
datetime3=`date +%T`
echo '=======================结束于'$datetime2 $datetime3'=======================' >>/www/wanleke/ftpshell/datainput.log
我的CRONTAB脚本如下
42 13 * * * /www/wanleke/ftpshell/datainput_test.sh >> /www/wanleke/ftpshell/datainput.log
shell crontab

------解决方案--------------------
42 13 * * * root  bash -x /www/wanleke/ftpshell/datainput_test.sh >> /www/wanleke/ftpshell/datainput.log
------解决方案--------------------
确认脚本被crontab执行了吗?
/www/wanleke/ftpshell/datainput.log里有没有东西?
------解决方案--------------------
你手动执行一下这个命令成功不:
mysql -u$user -p$passwd -h$host $dbname < wlk_uploadfile_20130416.sql

或者datainput.log有错误日志记录没
------解决方案--------------------
引用:
42 13 * * * root  bash -x /www/wanleke/ftpshell/datainput_test.sh >> /www/wanleke/ftpshell/datainput.log


替换成这个,看下日志里面执行脚本的全过程,就知道原因啦