Practical Bash Scripts for Linux System Administration and Automation
CPU Utilization Threshold Alert
Monitor processor load and trigger a notification when usage exceeds a defined limit. This implementation calculates active CPU time by subtracting the idle percentage reported by top.
#!/usr/bin/env bash
ALERT_LIMIT=75
CURRENT_LOAD=$(top -bn1 | awk '/^%Cpu/ {print 100 - $8}')
if awk "BEGIN {exit !($CURR ...
Posted on Sun, 10 May 2026 20:45:50 +0000 by Courbois
Real-Time File Synchronization Using inotifywait and rsync
Real-Time Directory Synchronization
In production environments, maintaining consistent file states across multiple servers is critical. A common requirement involves continuously mirroring changes from a primary directory—such as an NFS export—to a designated path on a backup server.
Core Synchronization Approach
Two widely adopted methods enab ...
Posted on Fri, 08 May 2026 00:23:39 +0000 by hazel999