crontab 与 shell 执行结果不一样

crontab 与 shell 执行结果不一样

本帖最后由 fujiefujie http://www.lampchina.net/ask/MTQxMzUwMg.html于 2011-2-28 10:38 编辑

shell
  1. #!/bin/bash  
     
  2. service httpd status &> /dev/null
     
  3. if [ $? -ne 0 ]
     
  4. then
     
  5.                day=`date "+%F%R"`
     
  6.                echo "service httpd is down at $day"  >> /var/log/htmon.txt
     
  7.                service httpd restart
     
  8.                service httpd status &> /dev/null
     
  9.                  
     
  10.                if  [ $? -ne 0 ]
     
  11.                then
     
  12.                           chkconfig --level 2345 httpd on  
     
  13.                else
     
  14.                           echo "httpd is running now..."
     
  15.                fi
     
  16. fi
复制代码
crontab

*/1 * * * * /opt/htmon.sh

 

你可能感兴趣的:(crontab,shell,职场,休闲)