This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
arduinohouse [2023/05/17 07:39] admin |
arduinohouse [2023/05/17 09:28] (current) admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | you need the process that monitors your process to be the process' | ||
+ | |||
+ | until myserver; do | ||
+ | echo " | ||
+ | sleep 1 | ||
+ | done | ||
+ | |||
+ | The above piece of bash code runs myserver in an until loop. The first line starts myserver and waits for it to end. When it ends, until checks its exit status. If the exit status is 0, it means it ended gracefully (which means you asked it to shut down somehow, and it did so successfully). In that case we don't want to restart it (we just asked it to shut down!). If the exit status is not 0, until will run the loop body, which emits an error message on STDERR and restarts the loop (back to line 1) after 1 second. | ||
+ | |||
+ | Why do we wait a second? Because if something' | ||
+ | |||
+ | Now all you need to do is start this bash script (asynchronously, | ||
+ | |||
+ | crontab -e | ||
+ | |||
+ | Then add a rule to start your monitor script: | ||
+ | |||
+ | @reboot / | ||
+ | |||
+ | Alternatively; | ||
+ | |||
+ | ----------------------------------------------------------------------------------------- | ||
https:// | https:// |