Skip to main content

On This Page

14 Essential Bash Scripts for Production Server Automation and Monitoring

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

14 Bash Scripts I Use on Every Production Server

Wealth Qubit developed a suite of 14 Bash scripts to eliminate repetitive manual server maintenance tasks across client environments. These tools integrate with Slack, Discord, and Email to provide automated recovery and monitoring for critical services like Laravel queue workers.

Why This Matters

In high-stakes production environments, the gap between ideal system stability and technical reality is often bridged by automated shell scripts that handle ‘3am failures.’ Manual monitoring is prone to human error and delayed response times, whereas scripts like selfheal.sh ensure service continuity by restarting crashed processes before users notice an outage. This approach reduces the cost of downtime and minimizes the need for complex, resource-heavy monitoring dashboards.

Key Insights

  • Self-healing automation via cron reduces downtime by using pgrep to monitor and restart failed artisan queue workers (Wealth Qubit, 2026).
  • Daily server digests delivered to Slack provide visibility into CPU, RAM, and disk usage without requiring a dedicated dashboard (Wealth Qubit, 2026).
  • Security pre-audits using vapt-check.sh identify .env exposure and missing HSTS headers before formal pentests (Wealth Qubit, 2026).
  • Zero-downtime deployment workflows automate the git pull, composer, and migration sequence with rollback alerts on failure (Wealth Qubit, 2026).
  • Automated MySQL backups with timestamped compressed dumps support Slack success notifications and optional S3 uploads (Wealth Qubit, 2026).

Working Examples

A self-healing script snippet designed to restart crashed Laravel queue worker processes every five minutes.

# Cron: */5 * * * *
pgrep -f "artisan queue:work" || php artisan queue:work &

Practical Applications

  • Laravel production servers utilize selfheal.sh to maintain queue worker availability. Pitfall: Incorrect pgrep patterns can lead to duplicate process execution if not properly scoped.
  • DevOps teams run vapt-check.sh to ensure .env files are not publicly accessible. Pitfall: Ignoring script warnings for missing headers can result in failed security audits and vulnerability exposure.

References:

Continue reading

Next article

Agent-Kernel: A Cognitive Operating System for AI-Assisted Development

Related Content