I have a vague idea how this works, could make something myself but I know someone out there will already have something or I’ll have to do some digging as I’m currently too busy to do it myself.
However my PI(s) have been having issues recently with my internet because of issues with my provider I’ve had a bit of an on/off connection - however whenever my internet restarts the PI doesn’t come back online without me unplugging it and restarting it manually. I can’t say I’ve had this issue in the past however I’m sure it never has in the past (or my net has never been off to notice).
So if anyone has anything to restart the PI’s wifi connectivity upon disconnection then feel free. I already have SSH and everything set up so I can control these remotely although this is an issue.
pi@raspberrypi ~ $ mkdir restart
pi@raspberrypi ~ $ cd restart
pi@raspberrypi ~/restart $ vi uptime.sh
pi@raspberrypi ~/restart $ chmod 755 uptime.sh
pi@raspberrypi ~/restart $ crontab -e
no crontab for pi - using an empty one
crontab: installing new crontab
Put that cron in, edited it to /restart/uptime.sh - hope for the best.
Cheers for the script, I found one or two that ping every second but I’d rather not waste all my resources pinging a site every second.
Once every 15 minutes is great though, hoping crontab works as myself and cron’s aren’t best of friends.
Checked /tmp/ at 23:00 and there isn’t anything as of yet.
Did you see the file created in your tmp directory yet? If it’s working you should see pingsuccess.txt in there.
If you don’t see it running in the cron run the script by hand ./uptest and make sure it works that way, then troubleshoot why your cron entry didn’t work.
It appears it wasn’t, I have managed to fix this though and it does appear to be logging; however could I set it as “192.168.0.1” as my own router or? Not like it’s a major issue sending a ping to google.
Most likely you own router will still respond when the internet is down, its doubtful your router stops responding too. I would keep it using Google personally.
Did you copy and paste into nano from my code above? It looks like maybe it split it on multiple lines? Line 7 should be the shutdown line so your error tells me your script has too many lines.