I executed the command below in a linux shell:
$ nohup run &
Here run is a blocking command. Then I close the shell and start a new one. However in the new shell I cannot bring the task to foreground via fg, nor can I see it via jobs. Is there still a way to bring it to foreground?
CodePudding user response:
From what I understand, run is a subprocess of the shell, and when the shell closes, run also closes.
Maybe using tmux or screen can achieve what you want.
CodePudding user response:
Use screen instead of nohup:
screen -dmS demo bash -c 'while ! read -t 1;do echo $((i ));done'
Note: there are no &.
Then exit... Later, you could:
screen -x demo
Hit keys Ctrl a, then d to leave console running
Or
gnome-terminal -e 'screen -x demo'
Then, simply close window to leave process running.
