linux - How to restart the python scrypts regardless of the reasons they've existed or crashed? -
say have sh script monitor python script , restart if crashes:
until myserver; echo "server 'myserver' crashed exit code $?. respawning.." >&2 sleep 1 done
while might work python script supposed work and exit, won't case because need python scripts (a few ones, not one) always work 24/7 in background. , if 1 of them ever exists means it's crashed , should restarted.
how should handle case?
if have root on system.
if have distro systemd.
then...
you can use systemd restart process ends using "restart=always". example:
[unit] description=my cool service after=network.target [service] execstart=/usr/local/sbin/myservice user=<myuser> group=<mygroup> restart=always [install] wantedby=multi-user.target
Comments
Post a Comment