Re: how do i check if a server is online ?
| From: | Robert Vetter | Date: | Tue, 27 Feb 2001 15:12:57 +0000 |
| Subject: | Re: how do i check if a server is online ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41834@lists.php.net to get a copy of this message | ||
"Markus H. Maussner" wrote:
>
> hi..
>
> i have the problem that i need to connect to a database on a server wich
> is quiet often offline.
>
> how can i connect to this database (mysql) and can check if the server is
> online.
> like.. if server is online -> fine we work as normaly
> if server is NOT online -> print out message and say "server offline try
> later"....
>
> i tried something like mysql_connect and then die ...
> but it takes approx 5 mins.. till i get the message..
> do i have to set the timeout lower? and if yes.. how do i do that ?
You could use ping command like this:
exec("ping -c 4 TheServer",$out_arr);
...and evaluate the $out_arr to see if the ping command was successful.
Robert