不停止程序(使用shell脚本)

发布于 2025-01-07 02:26:23 字数 104 浏览 1 评论 0原文

我有一个名为“mm.out”之类的二进制程序。这个程序有一些意想不到的错误,这些错误导致它停止。我想编写一个服务或 shell 脚本,以便在二进制文件意外停止时再次执行它。我该怎么写这个程序呢?

I have a binary program named as some thing like "mm.out". This program has some unexpected bugs and the bugs causes it to stop. I want to write a service or shell script to execute my binary again if it stopped unexpectedly. How should I write this program?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

骄傲 2025-01-14 02:26:23

你应该修复程序。但如果您确实想要这个,请循环运行它:

while ! mm.out
do
    sleep 5    # Just in case the program dies immediately
done

You should fix the program. But if you really want this, run it in a loop:

while ! mm.out
do
    sleep 5    # Just in case the program dies immediately
done
药祭#氼 2025-01-14 02:26:23

让 shell 脚本执行它并等待返回代码,如果该代码不是 0,则重新启动程序。

Let a shell script execute it and wait for a return code, if that code isn't 0 restart the program.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文