Automating Server Administration with Bash Scripts ๐

Managing Linux servers often means running repetitive commands to check disk space, analyze email logs, or review cron jobs.
I wanted to make this faster and easier โ so I created three Bash scripts that can do these tasks in seconds.
These scripts are built for CentOS, AlmaLinux, and similar distributions.
You can find the complete source code here:
๐ View on GitHub
๐ The Three Scripts
1๏ธโฃ diskreport.sh
Displays disk usage statistics in a clean, color-coded format.
Helps identify partitions running out of space before they become a problem.
2๏ธโฃ emailreport.sh
Analyzes Exim email logs for a time range you specify.
Shows:
Total sent emails
Bounce count
Top senders & recipients
Per-user email volume (for cPanel servers)
3๏ธโฃ cronreport.sh
Lists all cron jobs on the server.
Shows when they last ran, execution duration, and flags suspicious entries for review.
๐ How to Run the Scripts
Run Locally
chmod +x scriptname.sh
sudo ./scriptname.sh
Or:
sudo bash scriptname.sh
Run Without Saving (wget)
You can execute the script directly without saving it permanently:
sudo bash <(wget -qO- http://your-server-ip/scriptname.sh)
๐ Create a Systemd Service (Optional)
Want the script to run automatically or be easily triggered? You can create a systemd service.
Basic Steps:
1๏ธโฃ Place your script in /usr/local/bin/
This ensures it can be run from anywhere without specifying the full path.
2๏ธโฃ Create a service file
sudo nano /etc/systemd/system/myscript.service
Paste:
[Unit]
Description=My Custom Script Service
[Service]
Type=simple
ExecStart=/usr/local/bin/myscript.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
3๏ธโฃ Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable myscript.service
sudo systemctl start myscript.service
๐ Why I Built These
I work on servers where I need quick insights โ whether itโs disk space, email health, or cron job activity.
Instead of manually checking multiple commands and logs, these scripts provide one-command reports that are easy to read and act on.
๐ Get the Scripts
You can download all three scripts from my GitHub repository:
๐ GitHub: Server Administration Bash Scripts
If youโre into Linux server administration, DevOps, or automation, letโs connect:
๐ LinkedIn โ Mihir Savla
Subscribe to my newsletter
Read articles from Mihir Savla directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
