I want to write a script in php to ping an IP address. Scenario is that If ping fails, it should run a window service on the same system. ping must repeat 3-4 times every 30 second. Please help me in this problem. Thanks
What have you tried so far?
One issue you are bound to run into, if the IP address is down, it will be very complicated to run anything on the system that isn’t communicating.
I have currently tried static ip address only to check ping like
$ip = “127.0.0.1”;
exec(“ping -n 3 $ip”, $output, $status);
echo"
";";
print_r($output);
echo"
But could not understand what to do with 2nd stage when ping fails. I think it may have something to do with windows task scheduler. If you have ever worked on this kind of scenario then help me.
As I said, running anything against an IP that isn’t communicating is difficult, if not impossible.
Also, running PHP on Windows brings up a whole set of other issues.
It will be a few hours, but I have a script that I used for something like what you are attempting to do, though mine was just monitoring websites and logging outages.
Can you share it here may be it would be helpful for me.