Question: Writing a script which checks for an active Internet connection and adding a cronjob entry 1. Write a script named check-internet-status.sh and save it under

Writing a script which checks for an active Internet connection and adding a cronjob entry

1. Write a script named check-internet-status.sh and save it under /usr/local/sbin/

This script should:

a. With the help of the ping command, check whether you have an active connection or not. (Hint: You should parse the output of the ping command to determine the internet connection status)

b. Keep a log of your connection status in a file named internet-status.log under your home folder. i. Your home folder is /root ii. Make sure that the script appends the output to the log file rather than overwriting it

c. When keeping the log, your script should, in a single line, write the date and the status of your connection (online or offline) to the internet-status.log file.

d. You can use the date command to get the current date and time. Print the output of the date along with the internet status separated by a space in the internet-status.log file. e.g., Fri Sep 13 12:00:00 CDT 2019 online

e. Give your script the executable permission for your user account.

f. Create a cron entry in crontab for this script to run at 9:00AM every day.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!