Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Continuous Ping in Unix

Posted on 2011-04-27
11
Medium Priority
?
9,737 Views
Last Modified: 2012-08-14
In windows, you can do a continuous ping using 'ping -t'

How can you do the same in Unix?

Please specify if it's the same for Solaris and Red Hat.
0
Comment
Question by:deharvy
11 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 800 total points
ID: 35476380
ping on *nix systems has other parameters:
http://linux.about.com/od/commands/l/blcmdl8_ping.htm

so, the -t has another meaning.
and there seems to be no "endless" ping as such...

however, the *nix command line has it's own method to "repeat forever" commands:
http://unix.stackexchange.com/questions/10646/repeat-a-unix-command-every-x-seconds-forever
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35476397
Unix ping is by default continuous.

To limit the number of pings use the "-c number" option.

wmp
0
 
LVL 3

Expert Comment

by:Abhishek_Chib
ID: 35476431
By default is Continuous Ping
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:deharvy
ID: 35476474
I would think it was continuous ping by default as well, but after about 30 seconds, I get this:

# ping 192.168.1.5
no answer from 192.168.1.5

-----------------

After reading the 2nd article posted by angelII, I was able to find a bash script (while) that might do the trick.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1200 total points
ID: 35476496
That's a default timeout.

Increase it using the "-W" option:

ping -W 3600

will ping for 1 hour, even in absence of any answer.

wmp
0
 

Author Comment

by:deharvy
ID: 35476540
woolmilkporc,

I think we are on to something.

# ping -W 3600 192.168.1.5
ping: illegal option -- W
usage: ping host [timeout]
usage: ping -s [-l | U] [adLnRrv] [-A addr_family] [-c traffic_class]
        [-g gateway [-g gateway ...]] [-F flow_label] [-I interval]
        [-i interface] [-P tos] [-p port] [-t ttl] host [data_size] [npackets]

-----------------------

Even though the -W command didn't work for me, it showed me the usage and the timeout should follow the IP.

So, this is working just fine:

# ping 192.168.1.5 3600

Thanks!
0
 

Author Closing Comment

by:deharvy
ID: 35476563
The bash script works as well.

#!/bin/bash

while true
do
    ping 192.168.1.5 >> ping.log
    sleep 30
done
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35476571
What sort of Unix is this?

I never saw that format of ping before!
0
 

Author Comment

by:deharvy
ID: 35476589
# uname -X
System = SunOS
Release = 5.10
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35476625
Oh...

I occasionally worked with Solaris in the past - seems I never had to use ping with a timeout there!

Thx for the points!

wmp
0
 
LVL 9

Expert Comment

by:Amol
ID: 35484947
In Solaris, it will be ping -s 192.168.1.5
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question