使用 crontab 启动 wiremock-standalone 时出现问题
Issue when starting wiremock-standalone using crontab
我有一个使用 Wiremock 独立 JAR 的新回归套件。为了确保这是服务器上的 运行,我将这个脚本称为 checkwiremock.sh
#!/bin/bash
cnt=$(ps -eaflc --sort stime | grep wiremock-standalone-2.11.0.jar |grep -v grep | wc -l)
if(test $cnt -eq 1);
then
echo "Service already running..."
else
echo "Starting Service"
nohup java -jar /etc/opt/wiremock/wiremock-standalone-2.11.0.jar --port 1324 --verbose &
fi
当 运行 手动
时脚本按预期工作
./checkwiremock.sh
但是当开始使用 Crontab 时,
* * * * * /bin/bash /etc/opt/wiremock/checkwiremock.sh
Wiremock returns
No response could be served as there are no stub mappings in this WireMock instance.
我能看到手动启动的进程和 cron 进程之间的唯一区别是 TTY
root 31526 9.5 3.2 1309736 62704 pts/0 Sl 11:28 0:01 java -jar /etc/opt/wiremock/wiremock-standalone-2.11.0.jar --port 1324
root 31729 22.0 1.9 1294104 37808 ? Sl 11:31 0:00 java -jar /etc/opt/wiremock/wiremock-standalone-2.11.0.jar --port 1324
无法弄清楚这里出了什么问题。
服务器详细信息:
Red Hat Enterprise Linux 服务器版本 6.5(圣地亚哥)
*编辑:更正了实际使用的路径
将 checkwiremock.sh 中的目录更改为:
cd /path/to/shell/script
我有一个使用 Wiremock 独立 JAR 的新回归套件。为了确保这是服务器上的 运行,我将这个脚本称为 checkwiremock.sh
#!/bin/bash
cnt=$(ps -eaflc --sort stime | grep wiremock-standalone-2.11.0.jar |grep -v grep | wc -l)
if(test $cnt -eq 1);
then
echo "Service already running..."
else
echo "Starting Service"
nohup java -jar /etc/opt/wiremock/wiremock-standalone-2.11.0.jar --port 1324 --verbose &
fi
当 运行 手动
时脚本按预期工作./checkwiremock.sh
但是当开始使用 Crontab 时,
* * * * * /bin/bash /etc/opt/wiremock/checkwiremock.sh
Wiremock returns
No response could be served as there are no stub mappings in this WireMock instance.
我能看到手动启动的进程和 cron 进程之间的唯一区别是 TTY
root 31526 9.5 3.2 1309736 62704 pts/0 Sl 11:28 0:01 java -jar /etc/opt/wiremock/wiremock-standalone-2.11.0.jar --port 1324
root 31729 22.0 1.9 1294104 37808 ? Sl 11:31 0:00 java -jar /etc/opt/wiremock/wiremock-standalone-2.11.0.jar --port 1324
无法弄清楚这里出了什么问题。
服务器详细信息: Red Hat Enterprise Linux 服务器版本 6.5(圣地亚哥)
*编辑:更正了实际使用的路径
将 checkwiremock.sh 中的目录更改为:
cd /path/to/shell/script