Skip to main content

Command Palette

Search for a command to run...

Automating Server Administration with Bash Scripts πŸš€

Published
β€’2 min readβ€’View as Markdown

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