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

  • Home
  • SEARCH
  • 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 8075789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:06:24+00:00 2026-06-05T15:06:24+00:00

In Linux (Ubuntu), I want to programmatically check if there is Internet connection (or

  • 0

In Linux (Ubuntu), I want to programmatically check if there is Internet connection (or if eth0 is connected).

I’m doing this because I am writing a program that requires network connection on a system that is highly prone to lose connection.

So I was thinking maybe a script that I can run periodically to check.

Can you give me good suggestions?

  • 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-06-05T15:06:26+00:00Added an answer on June 5, 2026 at 3:06 pm

    Here is a quick script that will accomplish what you want:

    EMAIL=youremail@something.com
    ping -c 5 8.8.8.8 >> /dev/null
    
    if [ $? -eq  0 ]
        then
        echo "Able to reach internet!" | mail $EMAIL
    else
        echo "Unable to reach internet!" | mail $EMAIL
    fi
    

    Obviosly you can change the mail to something else to do depending on what your goal is
    EDIT: to explain, this pings googles dns server to ensure you are connected and sends you an email one way or the other. The email part on failure will only work of course if you have a local email server on your network.

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

Sidebar

Related Questions

I'm writing a few little bash scripts under Ubuntu linux. I want to be
Iam working on Ubuntu.(Linux) I want to redirect from the page one.php to two.php,
I'm working on Ubuntu.(Linux) I want to display all .php pages to .html in
Why when use Youtube-dl on linux ubuntu server many link generate this output? [youtube]
I've just installed Zend Studio 7.0.2 on my Linux-Ubuntu 9.10 system. There were no
I want to develop on 2 systems - using Linux (ubuntu) for server/git repo
I want to write a programme (in python) on Linux (Ubuntu Linux 9.10) that
I want to retrieve SCSI hard drive serial on Linux (Ubuntu) from a C++
I'm using Linux Mint (Ubuntu derivat) and want to install libClang with Cabal. The
When i connect with this code on my linux (Ubuntu 11.10) with mysql version

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.