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

crontab下执行重启脚本问题


crontab:29 16 * * * /home/ipnet/cdrm/sh/cargador_restart.sh >> /home/ipnet/cdrm/sh/restart.log

系统:[ipnet@ZJJX-NCAP-04 sh]$ uname -a
Linux ZJJX-NCAP-04 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux


脚本
#! /bin/sh
. /home/ipnet/.bash_profile
cd /home/ipnet/stope/bin
./Cargador.sh stop
sleep 5;
cd /home/ipnet/stope/bin
./Cargador.sh start
  echo "Cargador.sh restart success";
now=`TZ=$TZ-8; date +%Y-%m-%d-%H:%M:%S`
echo $now


出现的问题:
只能把Cargador.sh进行stop掉,但是不能够start起来

手动执行:
如果手动执行crontab,可以执行,正常start起来

[ipnet@ZJJX-NCAP-04 sh]$ /home/ipnet/cdrm/sh/cargador_restart.sh >> /home/ipnet/cdrm/sh/restart.log

求各位帮忙解答下,谢谢!或者有遇到这种问题的大大帮帮忙

------解决方案--------------------
一般可以认为是系统的环境变量没有加载全造成的
可以在脚本前source /etc/profile 之类的试试看,不知道你的启动脚本里涉及到哪些环境变量