Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens after i ctr+c during a nohup through ssh?

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
like image 253
alvas Avatar asked Oct 24 '25 15:10

alvas


1 Answers

If we leave stderr writing to terminal then disown needs to be called to remove this job or all the jobs from the job table.

So make sure you redirect stdout and stderr both using nohup and &:

nohup somecommand -option inputfile > outputfile 2>&1 &
exit

command would still be running.

like image 137
anubhava Avatar answered Oct 26 '25 09:10

anubhava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!