linux中 -daemon、&、nohup指这三者的区别
w, who am I, tty
w可得到当前用户的所有终端名称;
who am I与tty都可得到当前登录的终端是哪个
-
w :
-
who am I :
-
tty :
守护进程与后台进程的区别
(a)守护进程已经完全脱离终端控制台了,而后台程序并未完全脱离终端,在终端未关闭前还是会往终端输出结果
(b)守护进程在关闭终端控制台时不会受影响,而后台程序会随用户退出而停止,需要在以nohup command & 格式运行才能避免影响
⚡ root@di161 w
01:18:32 up 180 days, 8:48, 3 users, load average: 0.01, 0.10, 0.28
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 11.132.54.15 01:05 0.00s 0.23s 0.01s w
root pts/1 11.132.54.15 01:18 4.00s 0.12s 0.12s -zsh
root pts/2 11.132.54.15 01:18 2.00s 0.12s 0.12s -zsh
⚡ root@di161 tty
/dev/pts/0
⚡ root@di161 who am i
root pts/0 2020-08-16 01:05 (10.112.53.12)