Overview
I built a server health check in Bash that runs on its own with Cron. It checks memory, disk space and important services and reports the overall health of the server.
What I set out to do
- Run routine server health checks automatically and report a clear result.
What I did
- I checked the Cron setup.
- I ran the script by hand to see the report.
- I scheduled it with Cron.
Screenshots
They are in the same order as in my repository. Click one to see it full size.
1. Cron Environment CheckShows the Linux environment and Cron service configuration. 2. Health Check Manual TestShows the health-check script running manually and generating a system health report. 3. Scheduled Health CheckShows the Cron schedule configured to run the health-check automatically. 4. Automatic ExecutionShows Cron automatically executing the Linux health-check script. 5. Automatic Health Check ResultShows the health report generated by the scheduled execution. 6. Health Check Status EvaluationShows memory, disk and service checks being evaluated with OK status and an overall healthy result. 7. Failure DetectionShows the health-check detecting a simulated failure and returning a warning status. 8. Health Check Exit CodeShows the health-check returning Exit Code 0 when the system is healthy. 9. Final VerificationShows Cron automatically executing the health-check and the final healthy result with Exit Code 0.
How I tested it
- Cron ran the script on schedule and created the report.
- Memory, disk and service checks returned OK with an overall healthy result.
- When I simulated a failure the script caught it and returned a warning.
- The script returned exit code 0 when the server was healthy.
Repository
My full notes and the original screenshots are on GitHub: linux-projects/13-linux-server-health-monitoring