I did the following:
nohup find / &
rm nohup.out
Oddly, the nohup -command continued to run. I awaited for a new file to be created. For my surprise there was no such file. Where did the stdout of the command go?
Ending the nohup command with an & makes the command run in the background, even after you exit the shell. To exit the shell in this situation, enter the exit command. nohup ensures that the command does not end when the creating process ends.
Since there isn't a terminal to associate with it, nohup logs everything to an output file, nohup. out . By default, that file is located in whichever directory you started the command in. nohup.
nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out. Output that would normally go to the terminal goes to a file called nohup. out, if it has not already been redirected.
Run ping command with nohup command. Re-open the terminal and run pgrep command again. You will get the list of the process with process id which is running. You can stop any background process by running kill command.
if you will delete the nohup.out
file, the handle will be lost and it will write only to the file descriptor but if you want to clean out the nohup.out
file then just run this
true > nohup.out
it will delete the contents of the file but not the file.
cat /dev/null > nohup.out
from here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With