终端关闭后,程序保持后台运行
1、首选方法
自定义服务
2、使用setid指令将进程的ppid设为1,与tty无关
[root@vm666666 ~]# setsid [cmd] 2>&1
[root@vm666666 ~]# ps -ef | grep [cmd]
root 1869 1 0 Nov14 ? 00:29:25 [cmd]
root 32259 30715 0 13:20 pts/2 00:00:00 grep --color=auto [cmd]
参考:https://blog.csdn.net/chunyexiyu/article/details/86128835