简体   繁体   中英

How to know if the process is set NOHUP?

Using jobs I know the process is running.

bash-4.2$ jobs
[1]+  Running                 test.sh &

I wanted it to be set NOHUP so that it won't be killed when I exit. I used

disown

and

bash-4.2$ jobs

shows nothing. I'm not sure if the process is set NOHUP or not. I'm curious about this because after I read the manual it says

disown -h

should be used to set NOHUP.

Edit

I don't think the link Find the Process run by nohup command helps. The question is different than that one.

I'm gonna restate my problem. I run a program without nohup, and later I wanted it to be set NOHUP so that it won't be killed when I exit the system. So I used disown , but later I found the manual says I should have used disown -h to set NOHUP. I want to check if my process is set NOHUP or not successfully. If not, what can I do to set it to be NOHUP?

UPDATE

I know two ways my be helpful:

1) Whenever a process is running over nohup It writes output on ~/nohup.out . So you can check this file by running command find -cmin 2 . It shows you if nohup.out is changing each 2 seconds or not. If it is changing you would understand that sth is running by nohup command, after that you can check it with lsof and continue your checking...

2) If you logout from specific user andgo to tty then do ps aux | grep <user> ps aux | grep <user> or ps aux | grep ? ps aux | grep ? then you can understand that is running with nohup command... because there is no pts then it shows you ? instead...

useful command:

ps aux | grep <program> | awk -F" " '{print $7}'

Hope to be helpful

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM