Recall & Review
beginner
What is the main purpose of a service health check script?
To automatically check if a service is running properly and alert or take action if it is not.
Click to reveal answer
beginner
In a bash script, how do you check if a service is active using systemctl?
Use the command:
systemctl is-active service_name. It returns 'active' if running.Click to reveal answer
beginner
What does the exit status 0 mean in bash scripting?
It means the command or script ran successfully without errors.
Click to reveal answer
intermediate
Why is it useful to include logging in a service health check script?
Logging helps keep a record of service status checks and any problems found, useful for troubleshooting later.
Click to reveal answer
beginner
What is a simple way to restart a service in a bash script if it is not running?
Use
sudo systemctl restart service_name to restart the service.Click to reveal answer
Which command checks if a service is active in bash?
✗ Incorrect
The command 'systemctl is-active service_name' returns 'active' if the service is running.
What does the script usually do if the service is not active?
✗ Incorrect
If the service is not active, the script often restarts it to restore functionality.
How can you check the exit status of the last command in bash?
✗ Incorrect
The special variable '$?' holds the exit status of the last command.
Why should a health check script run regularly?
✗ Incorrect
Regular checks help detect and fix service problems early.
Which of these is a good practice in a health check script?
✗ Incorrect
Logging helps track service health over time and aids troubleshooting.
Describe how a simple bash script can check if a service is running and restart it if needed.
Think about commands to check status and restart services.
You got /4 concepts.
Explain why automating service health checks is helpful in system administration.
Consider benefits of automation and monitoring.
You got /4 concepts.