- 查询运行项目的进程
ps -aux|grep farbeat
- 杀死进程
kill -9 1600336
- 进入目录
cd /www/wwwroot/farbeat/
- 查看文件
ls
- 将日志输出在
nohup
文件中的方式启动项目(注意.jar
文件的名字)
nohup java -jar javaProject.jar &
- 实时查看
nohup
日志文件中的输出
tail -f nohup.out
- 查询最近200条日志记录
tail -n 200 nohup.out
- 用
.sh
文件方式启动
./run-dev.sh
.sh
文件的示例(注意.jar
的名字,prot
端口号,以及redis
的密码)
nohup /usr/local/java/jdk1.8.0_171/bin/java -Dfile.encoding=utf-8 -jar javaProject.jar --spring.profiles.active=dev --server.port=8080 --spring.redis.host=127.0.0.1 --spring.redis.password=666 &
- 停止服务的命令(注意
.jar
文件的名字)
#!/bin/sh RESOURCE_NAME=javaProject.jar tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'Stop Process...' kill -15 $tpid fi sleep 5 tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'Kill Process!' kill -9 $tpid else echo 'Stop Success!' fi sleep 2 tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'App is running.' else echo 'App is NOT running.' fi
- 启动的命令(注意
.jar
文件,端口,redis
的密码)
#!/bin/sh RESOURCE_NAME=GTWork.jar tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'Stop Process...' kill -15 $tpid fi sleep 5 tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'Kill Process!' kill -9 $tpid else echo 'Stop Success!' fi sleep 2 tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'App is running.' else echo 'App is NOT running.' fi rm -f tpid # nohup java -jar ./$RESOURCE_NAME --spring.profiles.active=prod & nohup /usr/local/java/jdk1.8.0_171/bin/java -Dfile.encoding=utf-8 -jar javaProject.jar -spring.profiles.active=dev -server.port=8080 -spring.redis.host=127.0.0.1 -spring.redis.password=666 & echo $! > tpid ing.profiles.active=dev -server.port=8080 -spring.redis.host=127.0.0.1 -spring.redis.password=666 & echo $! > tpid