Operating System - HP-UX
1833047 Members
2515 Online
110049 Solutions
New Discussion

How to send out one PING in HP-UX only.

 
SOLVED
Go to solution
Patrick_129
Advisor

How to send out one PING in HP-UX only.

Guys,

How to send one only one ping in HP-UX?

Thanks :)

patrickkuah
11 REPLIES 11
Naveej.K.A
Honored Contributor
Solution

Re: How to send out one PING in HP-UX only.

ping hostname/ipaddresss -n 1

this will send only one ICMP packet.

with best wishes
naveej
practice makes a man perfect!!!
A. Clay Stephenson
Acclaimed Contributor

Re: How to send out one PING in HP-UX only.

All you need to do is man ping. The man page explains it fully.

ping remotehost -n 1
If it ain't broke, I can fix that.
Steven E. Protter
Exalted Contributor

Re: How to send out one PING in HP-UX only.

ping hostname -n 1

You add a timeout of say 30 seconds with the -m 30 addition.

ping hostname -n 1 -m 30

tries one ping for 30 seconds before giving up.

ping hostname -n 1 -m 30
rc=$?

if [ $rc -ne 0 ]
then
echo "error, ping failed"
else
echo "ping worked"
fi

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Patrick_129
Advisor

Re: How to send out one PING in HP-UX only.

Thank guys :) This is what i need. I need to ping the gateway just to maintain the arp table.

patrickkuah
Patrick_129
Advisor

Re: How to send out one PING in HP-UX only.

How about sending one ping with every interval of 30 sec ? I do not wish to flood the network. If possble, reduce the packet size to the smallest. My objective is to maintain my gateway arp entry.
Naveej.K.A
Honored Contributor

Re: How to send out one PING in HP-UX only.

put the entry in cron to do it every 1 minute.

crontab -e
* * * * * /usr/sbin/ping hostname -n 1
save and exit

It will ping every minute one time

With best wishes
naveej
practice makes a man perfect!!!
KapilRaj
Honored Contributor

Re: How to send out one PING in HP-UX only.

man ping for PACKET_SIZE

Is it ping -s 1 ?? not sure but default is 56 bytes !

Kaps
Nothing is impossible
KapilRaj
Honored Contributor

Re: How to send out one PING in HP-UX only.

Also if your objective is to keep up an arp entry , It can be achieved by arp command ! just a thought note that ping is a broadcast ICMP !!

Kaps
Nothing is impossible
Trond Haugen
Honored Contributor

Re: How to send out one PING in HP-UX only.

Another option is to use a looping script:
while true
do
ping hostname -n 1
sleep 30
done &

You could start this from the command line, a rc script or inittab.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Sorrel G. Jakins
Valued Contributor

Re: How to send out one PING in HP-UX only.

I thought the arp table persisted, unless explicitly flushed?
Patrick_129
Advisor

Re: How to send out one PING in HP-UX only.

guys,

It ok, the problem was solved without writting the ping script.

Actually my senario is i have two load balancers which one is the primary and the other is the backup.
The problem is the failover portion, the mac address of the primary will change to the backup LB and after sometime, all my external client could not connect to the virtual ip anymore but for client in the same segment with the LBs are able to connect.

I found from a HP guy that there is a dead gateway detection feature which might caused this and i disabled it , It works!!! :)

Thank for the help :)