Packet_write_wait: Connection to xxx.xx.xx.xxx port 22: Broken pipe

#1

I am getting the message packet_write_wait: Connection to xxx.xx.xx.xxx port 22: Broken pipe. I assume this is due to long inactivity of my Terminal, my script is building up a weighted unifrac tree and it takes around 24 hours or more. I have seen similar issues raised but none regarding to the inactivity and how to overcome it except for : https://www.digitalocean.com/community/questions/why-am-i-getting-packet_write_wait-connection-to-xxx-xx-xx-xxx-port-22-broken-pipe

The problem is that when I try to type in: sshd_config I do not have access, can the admin of my server grant me access or is CLIMB that does not allow me to change those features? Any alternative to keep it running for such a long time?
*Also, I am using a virtual box to run it, I do not know if that may change the approach
Thanks!!

Jesús

#2

Hi Jesús

As your script is taking 24 hours, I suggest you run the script with nohup and &, like so:

nohup myscript &

Running your script like this means you can exit the terminal and your script will keep running in the background. Any output from the script will be written to a file called nohup.out. There’s a more detailed explanantion here: https://www.computerhope.com/unix/unohup.htm

Best wishes
Anna

#3

Hi annap,

Thank you very much, looks really good. I just run my script and I got the message: nohup: ignoring input and appending output to ‘nohup.out’
Does it mean that I can close my virtual box, switch off everything and the output would go the file that it was mean to, right? Also, I run it without the &, so there is no way to check if still running later on? If any error would happen would go to the nohup.out txt file?

Sorry for all the questions, but loos exactly what I was looking for, thanks again!

Jesús

#4

Hi Jesús

Yes, after using nohup you can close the terminal and your script will continue to run. Any message which is usually printed to the terminal, including error messages will go to nohup.out. If you go back into the terminal and use the command ‘top’ (ctrl+c to exit) you should see your script running.

It’s best to use the & with nohup, as using the & runs the script as a background process. It returns you to the command prompt and outputs a number called a pid, which will make it easier to track and manage your job

So if you do this:
ubuntu@myvm$ nohup myscript &

You’ll see something like the following output:
[1] 3456
ubuntu@myvm$ nohup: ignoring input and appending output to ‘nohup.out’

Press enter to continue, then use the following command to save the pid (3456 in this case) to a txt file:
ubuntu@myvm$ echo $! > pid.txt

You can then exit the terminal. To check if the script is still running later you can still use ‘top’ or you can use the following command:
ubuntu@myvm$ ps -ef | grep `cat pid.txt`
if it’s still running you’ll see your script listed.

You could also kill the script using:
ubuntu@myvm$ kill -9 `cat pid.txt`

Hope this helps!
Anna

#5

Hi again Anna,

Whoa, really, thanks! It’s really helpful I am just a bit scared because when I close the terminal I got the message “There is still a process running in this terminal. Closing the terminal will kill it” and it’s always a bit scary to see that, besides when I check with top I see many things going on but running is just “top” all the others and sleeping and I hope one of those is my script running in the background. There is one from user galaxy, may be that one? I suppose I’d realise when it’s done.
Yes, definitely, next time I would try with &

Thanks again,

Jesús

#6

You can also check nohup.out to see if it’s running successfully. ‘tail nohup.out’ will print the last 10 lines of the nohup.out file to the screen. Or you can use ‘cat nohup.out’ to see the whole file. If there’s no error message then it should be fine!

#7

Hi Anna, yes, so far no mistakes! Let’s see hot it goes, thank you very much!!

closed #8

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.