# 依据监听端口查询进程
netstat -tunlp |grep 6379
AppName=report.jar;
PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'`
if [ x"$PID" != x"" ]; then
kill -15 $PID
echo "$AppName (pid:$PID) exiting..."
sleep 3
else
echo "$AppName already stopped."
fi
# 查询Java程序
jps -lmvV
# 正常关闭
kill -15 进程号
# 关闭不掉强制关闭
kill -9 进程号
附:jenkins重启java程序脚本
BUILD_ID=dontKillMe
echo "打包路径:"
echo ${WORKSPACE}
cp ${WORKSPACE}/target/report.jar /home/report/report.jar;
cd /home/report;
AppName=report.jar;
PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'`
if [ x"$PID" != x"" ]; then
kill -9 $PID
echo "$AppName (pid:$PID) exiting..."
sleep 3
else
echo "$AppName already stopped."
fi
rm -f nohup.out
nohup java -jar $AppName --spring.profiles.active=prod >/dev/null 2>&1 &
echo "Start $AppName success..."
systemctl stop nginx.service
systemctl start nginx.service
systemctl status nginx.service
systemctl restart nginx.service
# 设置开机启动,一般都设置了
systemctl enable nginx.service
4.mysql脚本
#关闭mysql
systemctl stop mysqld
#启动mysql
systemctl start mysqld
#自动启动mysql
systemctl enable mysqld
#查看状态mysql
systemctl status mysqld
# 其他同上
systemctl start redis
# 其他同上
systemctl start jenkins
7.gitlab
gitlab-ctl stop
gitlab-ctl restart
gitlab-ctl start
gitlab-ctl reconfigure
gitlab-ctl status
#其他命令用
gitlab-ctl 查询