Originally Posted by mreff555
I was hoping for a bit of clarification about a few things related to forking and background process.
First: I infer that sending a process to the background doesn't automatically redirect the output since files that generate output still update to the screen. Am I right on this? if so, how could I echo the output to a file and send it to a background process.
second: There's many times when I've been connected remotely via ssh and run a command which will take a very long time to complete. If I send it to the background will that program continue to execute after I log off? if not what else would I have to do?
Third: Forking, whats it good for? could someone give me an example of how it might be used.
forth: I know a decent amount about the command line but I feel like these question I'm asking are more difficult to find than many others. Where could I find sources if information about various command line operators eg: %, |, &, !, /
1. Processes in the background send their output to the attached terminal which started them, for as long as the terminal remains attached. Sending output from a process to stdout and a file can be accomplished with the "tee" comand.
2. If you put a process in the background and log off, it will get the SIGHUP signal I think, and then will probably die. You can either "disown" the background process, or run it using "nohup" from the start. Either way, then the process will keep running after you log off.
3. One example of forking is for a server. It listens on a port. When it gets a connection, it forks off a child copy of itself to handle the connection, and the parent continues listening for the next connection. That way, the incoming job gets handled, and the server remains ready to handle more jobs.
4. "man bash" should explain all the details of those symbols. If you have a specific question, like "what does !! do?" for example, please ask.