linuxunixamazon-ec2pingnetwork-tools

Alternative to ping


I want to see if an Amazon EC2 instance is open, but by default Amazon EC2 blocks ping requests. There is a way to do this by changing the security policy of the instance. Excluding that, what would be the closest alternative to "see if a server is responsive" and is light-weight?

Is curl a good option?


Solution

  • I think curl is exactly what you want. Like all well-behaved unix programs, it returns an error code if anything goes wrong:

    [cnicutar@ariel ~]$ curl www.no-such-website.com
    [cnicutar@ariel ~]$ echo $?
    6
    

    Also you may want to use --connect-timeout to make sure it doesn't wait forever.