Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4626194
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:23:01+00:00 2026-05-22T03:23:01+00:00

Right, I have a PHP script at work where the server ping’s a client.

  • 0

Right, I have a PHP script at work where the server ping’s a client. The problem I am facing is that sometimes the server cannot contact the client although when I manually ping the client it ping’s successfully.

The ping command I am using is this ping -q -w 3 -c 1 < ipaddresshere >

What would be the best way of pinging the clients maybe 2/3 times leaving like a 2/3 second gap if a ping fails before a retry?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:23:01+00:00Added an answer on May 22, 2026 at 3:23 am

    As you are in the unix environment, you can always make and then call a shell script to handle the looping and waiting. But I’m surprised that you can’t do that inside of php.

    Also, i’m not sure about your sample ping command, the 2 different environments I checked seem to have different meanings for the options you mention than what you seem to intend. Try man ping OR ping --help

    The script below should give you a framework for implementing a ping-retry, but I can’t spend a lot of time on it.

    cat pingCheck.sh
    
    #! /bin/bash -vx
    
    IPaddr=$1
    
    : ${maxPingTries:=3}
    echo "maxPingTries=${maxPingTries}"
    
    pingTries=0
    while ${keepTryingToPing:-true} ; do
      if ping -n 3 -r 1 ${IPaddr} ;then
        keepTryingToPing=false
      else
        sleep ${sleepSecs:-3}
        if (( ++pingTries >= maxPingTries )) ; then
          printf "Execeeded count on ping attempts = ${maxPingTries}\n" 1>&2
          keepTryingToPing=false
        fi
      fi
    
    done
    

    I hope this helps.

    P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a PHP project that we would like to version control. Right now
Basically, we have an ASP website right now that I'm converting to PHP. We're
I have found this little script in PHP that send a simple request to
I have a problem with mysql connection. I have a php script which upload
I have a jQuery tab script that gets content from a PHP file defined
I have a jQuery tabbed search script that gets content from a PHP file
Right, I'm trying to write a wee script in PHP that will send an
I have an Apache server running on a client's computer, with PHP installed. I
I hope I can explain this right I have two input fields that require
Right now I have an SSIS package that runs every morning and gives me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.