0 Star 0 Fork 0

浪子花梦/技术文章收录

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
linux启动jar包脚本 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
浪子花梦 提交于 2024-08-19 14:40 +08:00 . update linux启动jar包脚本.
#!/bin/bash
# Function: Start, stop, restart, or check status of a JAR application
# Platform: All Linux Based Platforms
# Version: 1.1
# Date: 2023-03-XX
# Application details
APP_NAME="yudao-server-dev.jar"
DIR_NAME="/home/oa/dev"
JAR_PATH="$DIR_NAME/$APP_NAME"
LOG_FILE="$DIR_NAME/yudao-server-dev.log"
# Usage function
usage() {
echo "Usage: $0 [start|stop|restart|status]"
exit 1
}
# Check if the application is running
is_running() {
pid=$(pgrep -f "$JAR_PATH" | head -n 1)
if [ -z "$pid" ]; then
return 1
else
return 0
fi
}
# Start the application
start() {
if is_running; then
echo "$APP_NAME is already running. PID=$pid"
else
cd "$DIR_NAME"
nohup java -server -Xms512m -Xmx512m -jar "$JAR_PATH" > "$LOG_FILE" 2>&1 &
echo "$APP_NAME started successfully"
fi
}
# Stop the application
stop() {
if is_running; then
kill -9 "$pid"
echo "$APP_NAME stopped"
else
echo "$APP_NAME is not running"
fi
}
# Check the status of the application
status() {
if is_running; then
echo "$APP_NAME is running. PID=$pid"
else
echo "$APP_NAME is not running"
fi
}
# Restart the application
restart() {
stop
sleep 5
start
}
# Main logic
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
usage
;;
esac
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ithuameng/blog.git
git@gitee.com:ithuameng/blog.git
ithuameng
blog
技术文章收录
master

搜索帮助