Skip to content

Instantly share code, notes, and snippets.

@hplc
Created June 13, 2017 12:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hplc/53b5da26b2d804af3e6ac2cb3bdd5d44 to your computer and use it in GitHub Desktop.
Save hplc/53b5da26b2d804af3e6ac2cb3bdd5d44 to your computer and use it in GitHub Desktop.
Monitor service and restart it if down in OpenWrt.
#!/bin/sh
# Put this script run in crond.
service=ocserv
if test $(netstat -na | grep 0.0.0.0:443 | wc -l) = 2
then
echo "$service is running!"
else
/etc/init.d/$service start
fi
@M33FT
Copy link

M33FT commented Mar 5, 2021

I know it's a stupid question, but. . .
I am using the luci-app-https service, which is a type of "DNS Over HTTPS", and sometimes this service crashes due to a problem with my internet and I have to restart it again, because if I do not do this, no "Website" will not open.
I did not work with the script file in Openwrt and I do not know the script commands.
Can you tell me exactly where I should put this script?
Do you mean Crontab?

crontab

And do I have to do the following to restart the luci-app-https service after a 50 second pause?

crontab_02

Thanks bro
@hplc

@M33FT
Copy link

M33FT commented Mar 5, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment