I have a code running on a Linux server. Since it takes hours to run, I have to use nohup
to make sure my code is still running in case I loose my connection to the server. Again since I have to wait hours to see the results, I defined a counter to print out the progress of my code (%). If I loose my connection to the server or close the terminal, the only way that I can see the code is still running is using top
. Is there any way that I can see again the output console (message showing the progress)?
nohup. out file will be in location of your present working directory ,pwd. (the directory from where you executed command).
If you see the name of your process/program among those listed then it hasn't finished yet. To check the results or status of the programs, log back in to the same server. Once the job has finished its output will be contained in a file located within your home space. The filename will be "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. nohup.
If you want to redirect the output of nohup command to file, just add it at the end of command after > redirection operator. Here is an example. In this case, the output of shell script will be sent to /home/ubuntu/data. txt file.
You can see the output in real time by running below from another terminal.
tail -f nohup.out
You can redirect standard output and standard error to a file and look at that file. eg:
nohup command 2>&1 > outputfile &
note default behavior from man page:
If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it to standard output
so really you can just run
nohup command &
and then look in nohup.out
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