0

I'd like to have a script running in the background, which pings a remote host every 10 seconds or so. The script looks something like this:

nohup ping -i 10 www.google.com &

I'm able to initiate the script with an @reboot cron job, following this suggestion. However, the ping doesn't happen in the background and I don't see the script running when I poke around with ps.

Any suggestions much appreciated. Thanks.

4
  • 3
    if you put it like that in cron I got a question where is ping located? (answer: always use absolute paths in cron unless you can tell it to use a PATH ;) ) – Rinzwind Dec 10 '19 at 22:09
  • 1
    Try the commands with absolute paths, as described by type. The command should be /usr/bin/nohup /bin/ping -i 10 www.google.com & .BUT! is name resolution (dnsmasq) up and running when @reboot runs? Try @reboot host www.google.com. I have a different suggestion, adapt this: github.com/waltinator/net-o-matic.git - Watch for (WiFi) network going down, then do a user-specified thing to fix it. – waltinator Dec 10 '19 at 23:05
  • Why on earth do you need/want to ping google every 10 secs? – heynnema Dec 11 '19 at 0:14
  • long-ish answer, I run a high school computer lab where computers are on wifi. I am having trouble at times ssh'ing to various boxes and I'm trying to determine if the radio is timing out. Hoping that a ping keep alive will keep the wifi interface alive. I have disabled the sleep / power save, but still having trouble. it may be network traffic ... when I started this project it seemed like it would be an easy route to get a keep alive like this going in the background. And hey, I learned a bit more about Ubuntu. – ether_joe Dec 11 '19 at 1:48
0

I needed to switch from using a cron job, to adding a script to /etc/network/if-up.d/ as per this suggestion. Did some troubleshooting with ifup --all -v to get the details correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.