1

I'm on a shared sever without sudo. I'm using a program running off mono that crashes frequently on a Debian server. What's the best way to have the process auto-restart?

1 Answers1

1

In systemd you can create a service file to (re)start your process. You can add this file in /etc/systemd/system or in /etc/systemd/user.

This will take care of starting your program when the server reboots or when your program crashes. You can look at the existing files there for examples and also have a look at the manual.

If you just want to start it from the commandline and have it restart when it exits, you can create a bash script that wraps your command. For example:

#!/bin/bash

while (true) do
   echo starting...
   # your command goes here instead of sleep
   sleep 4
   # show result
   exitcode=$?
   echo "exit code of command is $exitcode"
done

This is the simplest form, which does no checking at all.

NZD
  • 2,818