Server

Keep Service Running after Exiting SSH – Systemctl Service

sudo loginctl enable-linger your-username

your-username is the username of which you’re running the systemctl service.

So is this your villain backstory?

You’re running a systemd systemctl service such as your gunicorn via the user account, instead of putting the service under sudo i.e in the /etc/systemd/…` folder.

You’re doing this because you want to be able to restart the service via a remote action, such as github actions.

But then anytime you exit your remote ssh, your gunicorn service via systemd stops working, because somehow the service is tied to your user session?

Great! The above command is your solution. It’ll persist the service and not tie it to your ssh user session.

Related Articles

Back to top button