unixsshremote-accessnohup

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

Solution

  • 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.