Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep a server processing running on a Google Cloud VM?

This question seems very basic, but I wasn't able to quickly find an answer at https://cloud.google.com/compute/docs/instances/create-start-instance. I'm running a MicroMDM server on a Google Cloud VM by connecting to is using SSH (from the VM instances page in the Google Cloud Console) and then running the command

> sudo micromdm serve

However, I notice that when I shut down my laptop, the server also stops, which is actually why I wanted to run the server in a VM in the first place.

What would be the recommended way to keep the server running? Should I use systemd or perhaps run the process as a Docker container?

like image 791
Kurt Peek Avatar asked Sep 06 '25 03:09

Kurt Peek


1 Answers

When you run the service from the command line, you "attach" it to your shell process, when you terminate your ssh session, your job gets terminated also.

To make a process run in background, simply append the & at the end of the command, in your case:

sudo micromdm serve &

This way your server is alive even after you quit your session. I also suggest you to add that line in the instance startup script, if you want that server to always be up, so that you don't have to run the command by hand each time :)

More on Compute Engine startup scripts here.

like image 128
Pievis Avatar answered Sep 07 '25 20:09

Pievis