如何在Linux上的后台无限运行脚本? [英] How to run infinitely script in background on Linux?

查看:74
本文介绍了如何在Linux上的后台无限运行脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个无限循环的PHP脚本.我需要这个脚本永远运行.因此,我运行

I have a PHP script with infinite loop. I need this script running forever. So, I run

php /path/to/script.php > /dev/null &

它在我当前用户的安全上下文中在后台运行.但是,当我关闭终端窗口(注销)时,CentOS Linux当然会杀死我的程序.

And it works in background in my current user's security context. But when I close terminal window (log off), of course, CentOS Linux kills my program.

我看到两个猜测:在后台从另一个用户运行或创建守护程序.在每种情况下我都需要帮助.

I see two guesses: run from a different user in background or make a daemon. I need help in each situation.

非常感谢!

推荐答案

nohup是你的朋友.

nohup is your friend.

nohup command &

这篇关于如何在Linux上的后台无限运行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆