When you background things from an shell, they get allocated job IDs which are something
internal to that shell. The
process ID (pid) is system wide, and should be visible even after the shell terminates.
In the case of bash, when you start a program in the background, it tells you both the shell's job ID and the pid of the process which has been started, like this:
Code:
% sleep 500 &
[1] 6982
In this case, 1 is the job ID and 6982 is the pid.
Many programs which are run in the background in this way will terminate when the user disconnects from the terminal. This is because the system will send the signal HUP (hang up) then the terminal is dis-connected from the shell. The default behaviour of processes which receive this signal is to quit. The purpose of nohup is to intercept this signal and not pass it to the child process. Thus a process may continue to operate even when the user disconnects from the controlling terminal.
In the case where you are using ssh to connect to a machine and run wget with nohup, the process should continue after you disconnect. However, the record of the job ID dies with the interactive shell. When you log in again, a new shell process is started, and it has no information about the jobs of other shells. However, the wget process is probably still running (assuming it didn't terminate because it is finished, or suffered an error). You can check this by looking by process id.
The
ps command used with no options will only show information about processes which are connected to the current terminal. To show processes which are connected to other terminals, (or those processes with no associated terminals), you can use some extra options. To see all wget processes on the system, try this:
You may see your previously run wget process still running.
There is a small problem however - how do you re-connect to it? Well, using normal shell job control there is no way AFAIK. You can send signals to the process using the
kill command, which enabled you to terminate the process, and in the case of some programs instruct it to do other things (such as re-open log and config files).
As mentioned above, the program
screen can be used to provide dis-connectible and re-connectible terminal sessions, among other things. It's very useful, but it's not installed everywhere.