简单记录个启动脚本

#!/bin/bash
# /etc/profile
DataPath="/cloud/sync/syncData"
echo "[info][$(date +'%F %H:%M:%S')]正在监控syncData,路径:$DataPath"
pid=`ps -ef | grep syncData | grep -w $DataPath | grep -v 'grep' | awk '{print $2}'`
if [ -n "$pid" ]; then
echo "[info][$(date +'%F %H:%M:%S')]syncData进程为:$pid"
echo "[info][$(date +'%F %H:%M:%S')]syncData已经启动,准备使用stop命令关闭..."
$DataPath"/syncData.sh stop"
sleep 2
pid=`ps -ef | grep syncData | grep -w $DataPath | grep -v 'grep' | awk '{print $2}'`
if [ -n "$pid" ]; then
echo "[info][$(date +'%F %H:%M:%S')]使用stop命令关闭失败,准备kill进程..."
kill -9 $pid
echo "[info][$(date +'%F %H:%M:%S')]kill进程完毕!"
sleep 1
else
echo "[info][$(date +'%F %H:%M:%S')]使用stop命令关闭成功!"
fi
else
echo "[info][$(date +'%F %H:%M:%S')]syncData未启动!"
fi
echo "[info][$(date +'%F %H:%M:%S')]准备启动syncData..."
$DataPath"/syncData.sh stop"

 

posted @ 2023-07-12 16:14  黑墨罗少  阅读(13)  评论(0编辑  收藏  举报