写了一个小程序,后台每秒会向文本文件写一行当前时间
分别有三种情况
1、nohup java -jar test.jar
此时后台会打印
[scfpcp@localhost ~]$ nohup java -jar test.jar
nohup: ignoring input and appending output to `nohup.out'
然后就卡住了。但是java进程已经接收不到HUP信号了,虽然我不清楚这个HUP信号是干什么的。但是此时,后台程序一直在不停的输出。
如果此时敲Ctrl+C,则程序进程会终止。
如果此时关闭终端,也就是关闭shell,则程序进程不会停止,还会不停的写。
2、java -jar test.jar &
此时后台会打印
[scfpcp@localhost ~]$ java -jar test.jar &
[1] 11474
[scfpcp@localhost ~]$
然后又回到shell了
如果此时敲Ctrl+C,则程序进程不会收到影响。
如果此时关闭终端,也就是关闭shell,则程序进程则会停止。
再进去终端,java进程不在了
3、nohup java -jar test.jar &
此时后台会打印
[scfpcp@localhost ~]$ nohup java -jar test.jar &
[1] 11602
[scfpcp@localhost ~]$ nohup: ignoring input and appending output to `nohup.out'
[scfpcp@localhost ~]$
如果此时敲Ctrl+C,则程序进程不会收到影响。
如果此时关闭终端,也就是关闭shell,则程序进程也不会停止,继续执行。