Hi ,
i need a script in crontab that check ping and reboot “network” if ping fails.
something like this
#!/bin/bash
count=$( ping -c 3 XXX.XXX.XXX.XXX | grep icmp | grep bytes | wc -l )
if [ $count -eq 0 ]
then
?¿?¿?¿?¿?¿?¿?¿?
fi
how to reboot network in osmc??? what cli command??
Thanks & Regards
P.D : Sorry my english
Hi. First of all, I must say that I have never had to reboot the network interface (in my case eth0) on OSMC, either on a Raspberry Pi or a Vero 4K. Are you sure that you really need to do this?
First, you don’t say if your network interface is wired or wireless (ethernet or wifi). Wireless can be affected by interference from microwave ovens, baby alarms and, of course, other wifi devices nearby. It would not be wise to even think about restarting your wifi interface if you have a break of just a few seconds.
Second, you don’t say what IP address you’re pinging. Unless it is your own local router, your pings can be delayed at any point on the internet. A failed ping does not mean that the OSMC network needs to be rebooted. Even if you ping your local router, who is to say that the problem does not lie with the router or caused by something else?
My advice would be: unless you have already had multiple occasions when the network locked up on your OSMC box, I’d suggest you leave it for now.
Hi, thank for your answer.
Its a RaspberryPi 3 with wireless integrated.
Im using wireless and sometimes loses connections.
Its connected to my tv and nothing around.
Wireless Router in the same room (<3m).
Tested with another router.
This issue makes loses connection and broke PiHole,VPN,SSH…
When this happens i have to reboot manually.
I only want to automate this pinging router IP.
Only need cli command to restart .
Something like this
systemctl restart network-manager.service
thanks in advance
You could try:
systemctl restart connman
Edit: A possible alternative
connmanctl disable wifi
connmanctl enable wifi
Is a wired connection really not possible?
Hi ,
thank for the info!!!
#!/bin/bash
count=$( ping -c 3 192.168.5.1 | grep icmp | grep bytes | wc -l )
if [ $count -eq 0 ]
then
connmanctl disable wifi
sleep 1m
connmanctl enable wifi
fi
I need to sleep 1 minute waiting to disable and then enable again.
Test works fine
Time will say if it works correctly.
Regards