I have a wireless repeater which for some reason loves to go into sleep mode all the time, even if it is not supposed to. The manufacturer swears it's not a defect, and when it works, it works great.

I have noticed that when I ping it continuously, it will stay awake as long as the ping continues, give it 2-3 minutes of no ping, it will sleep and not wake up.

Long story short, I have a linux server in the office, and I was wondering if I could setup a command to continuously ping the ip address as soon as the server is booted, and never stop until I shut the server down.

What would I need to set this up?



This can be trivially achieved using cron with some specific parameters to ping.

Create a file with a name like perhaps /etc/cron.d/ping-my-repeater. For contents, pick one of the below.

If once per minute is adequate, try this:

* * * * * root ping -n -c 1 -W 1 $REPEATER_IP_ADDRESS

If twice per minute is desired, try this:

* * * * * root ping -n -c 2 -i 30 -W 1 $REPEATER_IP_ADDRESS

If every 15 seconds is desired, try this:

* * * * * root ping -n -c 4 -i 15 -W 1 $REPEATER_IP_ADDRESS

The -c specifies count, -i specifies interval between echo requests in seconds, and -W specifies time to wait for each reply in seconds. -n says numeric output only, and particuarly suppresses remote IP address reverse name resolution. * * * * * means execute the command once per minute, and root is the user to execute the command as.

Please don't point something like this at an IP address not under your physical control without the consent of the owner of the remote host.

Once you are satisfied that it works, you can suppress the email output generated by adding a line such as


at the top of the file.

The way this works is that ping sends one ICMP echo request and waits -W seconds for the response, then if more echo requests should be sent waits -i seconds before sending another one. So the first one is sent immediately, the second (e.g.) 15 seconds after the response to the first was either received or timed out, the third another 15 seconds later, and the fourth another 15 seconds later, for a total wall clock runtime of approximately 45 seconds. At the top of the next minute, ping is launched again and the process is repeated.

You can also launch ping through e.g. /etc/rc.local (may have a different name on your system), skip the -c N option and let ping run indefinitely; however that can sometimes play badly with boot sequencing, and if something causes ping to terminate unless you take specific steps to check for that it won't be restarted automatically.

| improve this answer | |
  • alright, so I made the files, how do I run them? Just reboot the server? – JonYork Jul 17 '14 at 16:32
  • 1
    @JonYork cron should pick up on the added file automatically, assuming that it is running. Give it a moment then check root's mailbox (or any mailbox it is redirected to) for output. – a CVn Jul 17 '14 at 16:36

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.