1

I had a spare pi lying about, a model 4b with 2GB ram, and recently I had been playing alot of Minecraft games with my freinds over lan from my pc but realised I could setup a server off my pi. But after setup whilst my freind was playing on it I decided to close the ssh connection I used for the setup ,I run my pi in headless mode with Raspbian lite, but was oblivious to the fact that after I closed the connection the server also closed, I only realised when my freind asked me why was the server down.

I cannot keep the ssh connection open as after some time it gets a broken pipe error, I could prevent this by entering some random command like ls to keep it alive but I'm not always there to hold its handbut if I was realy I was thinking to just set it up and leave it there to do what a minecraft server does. I have tried to start the server with the & suffix but it suspends itself early in the servers startup, however i had more succes using the nohup command which workswell but doesnt allow me to give input to the server which would be desireable. I have no clue how to achieve this and have been hitting my head on the table over this, any help would be great.

Thanks,

0

This is because the ssh does not run things in the background when you run a normal command. One way to do this is to use systemd/systemctl to create a background service that will run your server. Here is a guide on how to set up a service (https://domoticproject.com/creating-raspberry-pi-service/).You can also set this up to

Note: if you're connecting your service to bash/.sh file you need this string at the top of your file #/bin/bash

Also, if you want to view the logs of your service you can run journalctl -e -f -u <your service name>.service

If you want a maybe slightly simpler way to do this, here's an article specifically for ssh connections: https://www.tecmint.com/keep-remote-ssh-sessions-running-after-disconnection/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.