一个简单但是实用的小shell脚本

近日调试程序,因为CGP的服务器要求复制更新文件后需要重启才能使文件生效,所以每次更新文件都需要手工重启一下CGP服务器,甚是麻烦,所以使用几个简单的命令,写了个shell,用着挺省心,贴上源码:

#!/bin/sh

#define path to be watched
SPY_PATH=/var/CommuniGate/Domains/ruyi.com/WebSkins

#create file tap.lst and initial it
if [ -f "tpa.lst" ]; then
 echo -n ""
else
 echo "---" > tpa.lst
fi

#loop and pause serveral seconds
while [ 1=1 ]; do
line=
ls -ltr --time-style=full-iso  $SPY_PATH | grep -E ".wss|.js" > tp.lst
tail -n1  tp.lst > tpo.lst
line=$(cmp tpo.lst tpa.lst)
if [ -n "$line" ];
then
  rm -f tpa.lst
  cp  tpo.lst tpa.lst
  #restart CGP Server (stop then start), the command can be replaced with other commands you need
  /etc/init.d/CommuniGate stop
 
  /etc/init.d/CommuniGate start
  echo ""
  echo -n "=========================================="
  echo $(date +"%F %X")
else
 echo -n ""
fi
#echo -n "loop....."

sleep 3
done
exit 0

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值