You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用nohup在Linux后台启动JMeter的Simple Table Server

在Linux后台运行Simple Table Server的正确方法

直接使用nohup的标准命令

用nohup实现后台运行的标准写法如下,无需额外加disown:

nohup ./simple-table-server.sh > output.log 2>&1 < /dev/null &
  • nohup:让进程忽略终端关闭时发送的SIGHUP信号,保证进程持续运行
  • > output.log 2>&1:将标准输出和错误输出重定向到日志文件
  • < /dev/null:避免程序因尝试读取标准输入而意外退出

排查之前命令失效的常见原因

  1. 脚本无执行权限:先执行chmod +x simple-table-server.sh赋予脚本可执行权限
  2. 环境变量缺失:如果脚本依赖特定环境变量(如JAVA_HOME),可在命令前指定或在脚本开头添加变量定义,例如:
    nohup JAVA_HOME=/usr/lib/jvm/java-11-openjdk ./simple-table-server.sh > output.log 2>&1 < /dev/null &
    
  3. 日志无输出/进程退出:查看output.log内容,定位脚本启动失败的具体错误(如依赖缺失、配置错误)

验证进程状态

运行命令后,用以下方式确认服务是否正常运行:

ps aux | grep simple-table-server
# 或更简洁的方式
pgrep -f simple-table-server.sh

更可靠的长期运行方案(systemd)

如果需要服务自动重启、开机自启,可创建systemd服务:

  1. 创建服务文件/etc/systemd/system/simple-table-server.service:
[Unit]
Description=Simple Table Server
After=network.target

[Service]
Type=simple
ExecStart=/绝对路径/simple-table-server.sh
WorkingDirectory=/脚本所在目录路径
StandardOutput=append:/var/log/simple-table-server.log
StandardError=append:/var/log/simple-table-server.log
Restart=always

[Install]
WantedBy=multi-user.target
  1. 重载systemd并启动服务:
systemctl daemon-reload
systemctl start simple-table-server
# 设置开机自启
systemctl enable simple-table-server

内容的提问来源于stack exchange,提问作者That'llDoPig

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 09:55:55