在shell脚本中杀死并重新启动ngrok
我需要每24小时关闭并重新启动我的在shell脚本中杀死并重新启动ngrok,shell,sh,ngrok,Shell,Sh,Ngrok,我需要每24小时关闭并重新启动我的ngrok服务器,所以我考虑使用cronjob来运行shell脚本。我面临的问题是,当我在shell脚本中重新启动ngrok时,它会在给定的shell会话中启动它 如何在不同的会话中启动ngrok,以便在同一脚本中继续执行其他检查 到目前为止,我掌握的代码是: # grabs the PID for the current running ngrok ngrok_pid=$(pgrep ngrok) echo "Current ngrok PID = ${ngr
ngrok
服务器,所以我考虑使用cronjob来运行shell脚本。我面临的问题是,当我在shell脚本中重新启动ngrok
时,它会在给定的shell会话中启动它
如何在不同的会话中启动ngrok
,以便在同一脚本中继续执行其他检查
到目前为止,我掌握的代码是:
# grabs the PID for the current running ngrok
ngrok_pid=$(pgrep ngrok)
echo "Current ngrok PID = ${ngrok_pid}"
# kills ngrok
kill_ngrok_pid=$(kill -9 $ngrok_pid)
# get exit status code for last command
check=$?
# check if the exit status returned success
if [ $check -eq 0 ]; then
# re-start ngrok
$(./ngrok http 5000 &)
# do more checks below...
else
echo "NO ngrok PID found"
fi
在GNU屏幕分离会话中启动ngrok怎么样<代码>屏幕-d-m ngrok http 5000。然后您可以连接到屏幕会话以查看ngrok的stdout。同时查看Screen的
-h
选项。我看不出$(/ngrok http5000&)
增加了任何优势。我希望/ngrok http 5000&
允许脚本继续并执行其他操作(如果需要屏幕
捕获输出,或者允许使用内部(到ngrok)命令行),那么我认为屏幕
是唯一的方法。祝你好运