Issue
I've some questions about nohup. Below shows the commands and results i've tried. If i have to use nohup ... &
and then disown
, then what's the use of the nohup
? I could have simply use ... &
and then disown
.
Run a command with nohup
and then ctr+c , the command didn't continue
$ nohup somecommand -option inputfile > outputfile
nohup: ignoring input and appending output to `nohup.out'
^C
Run command with nohup ... &
and then ctr+c, the command continues but stops after exit
$ nohup somecommand -option inputfile > outputfile &
nohup: ignoring input and appending output to `nohup.out'
^C
$ exit
Run command with nohup ... &
and then ctr+c, the command continues even after exit
$ nohup somecommand -option inputfile > outputfile &
nohup: ignoring input and appending output to `nohup.out'
^C
$ disown
$ exit
Run command with without nohup
and then ctr+c, the command continues even after exit
$ somecommand -option inputfile > outputfile &
nohup: ignoring input and appending output to `nohup.out'
^C
$ disown
$ exit
Solution
Make sure you redirect stdout and stderr both using nohup
and &
nohup somecommand -option inputfile > outputfile 2>&1 &
exit
command would still be running.
Answered By - anubhava Answer Checked By - Pedro (WPSolving Volunteer)