1.cpfile
#! /bin/sh
echo "Start Copy!!!"
cp -r /tmp/$1 .
echo "End Copy!!!"
cd $1
2.log
#! /bin/sh
file=$PWD
name=${file##*/}
tail /tmp/melog/$name.log -f
3.restart
#!/bin/bash
tmppath=$PWD
name=${tmppath%/*}
realname=${name##*/}
echo "$realname"
exe=$realname
#PID=$(ps -ef |grep $realname | grep -v grep | awk '{print $2}'|awk -F '/' '{print $1}')
cfg=info.txt
logFilePath=/tmp/2021/$exe
if [ ! -d $logFilePath ];then
mkdir $logFilePath
fi
if true; then
PID=`ps -x | grep $exe | grep -E -v 'grep|tail' | awk '{print $1}'`
if [ -n "$PID" ]; then
for pid in `ps -x | grep $exe | grep -E -v 'grep|tail' | awk '{print $1}'`; do
echo "kill $pid"
kill $pid
done
p_num=`ps x | grep $exe | grep -E -v 'grep|tail' | wc -l`
while [ $p_num -gt 0 ]; do
sleep 0.1
p_num=`ps x | grep $exe | grep -E -v 'grep|tail' | wc -l`
done
fi
else
if [ -n "$PID" ]; then
kill -15 $PID
echo "kill $PID successful"
else
echo "jar is not running $PID"
fi
fi
log=$exe.log
logBak=$exe.$(date +"%Y%m%d-%T").log
if [ -f $logFilePath/$log ]; then
mv $logFilePath/$log $logFilePath/$logBak
echo "mv $logFilePath/$log $logFilePath/$logBak"
fi
nohup ./$exe $cfg >$logFilePath/$log 2>&1 &
echo " ./$exe $cfg >$logFilePath/$log"
4.debug
#! /bin/sh
file=$PWD
name=${file##*/}
echo "$name"
make
if [ -f "exe/$name" ];then
echo "rm -f exe/$name"
rm exe/$name
fi
mv $name exe/
cd exe
chmod 777 restart
./restart