您的位置:首页 > 运维架构 > Linux

使程序在Linux下后台运行 (关掉终端继续让程序运行的方法)

2020-05-02 18:23 906 查看

使程序在Linux下后台运行 (关掉终端继续让程序运行的方法)

将程序转入后台运行

# nohup [执行代码区] &  如下
nohup ./test.sh &

终止后台进程, 首先查找进程

#ps -ef | grep [关键字]  如下:
ps -ef | grep test.sh

####################################
root 847 1 0 11:47 ? 00:00:02 /usr/bin/python -Es /usr/sbin/tuned -l -P
root 28326 28210 0 18:05 pts/0 00:00:00 grep --color=auto py

终止进程

# kill -9 PID (PID 为查找到相应记录的第二个参数)
kill -9 847

意外情况1

nohup: ignoring input and appending output to ‘nohup.out’

解决方案:

#php server.php替换成你要执行的代码
nohup php server.php  </dev/null &>/dev/null &

来自链接:https://www.jianshu.com/p/f6cccd755436

xing1979 原创文章 6获赞 1访问量 260 关注 私信
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐