Premium
BASH Snippets.

Curated list of production-ready BASH scripts and coding solutions.

BASH

Efficiently Syncing Local Files to a Remote Server with Rsync

Leverage rsync for fast, incremental file synchronization to deploy web application updates or backups to a remote server, saving bandwidth and time.

View Snippet →
BASH

Real-time Monitoring of Apache/Nginx Error Logs for Critical Issues

Monitor web server error logs (Apache or Nginx) in real-time, filtering for critical error messages to quickly identify and respond to production issues.

View Snippet →
BASH

Basic Health Check for a Web Service URL

Perform a simple yet effective health check on a web service URL, verifying its reachability and successful HTTP status, with optional retries.

View Snippet →
BASH

Unified Script for Clearing Application Caches (e.g., Laravel, Node.js)

Streamline your development workflow with a flexible bash script to clear various application caches (Laravel, Node.js, Composer) based on project type.

View Snippet →
BASH

Loading Environment Variables from .env File

A bash script to efficiently load key-value pairs from a .env file into the current shell's environment, streamlining application configuration.

View Snippet →
BASH

Automating Basic Project Directory Structure Creation

A simple bash script to quickly scaffold a new web project's common directories like src, public, config, and logs, enhancing development workflow.

View Snippet →
BASH

Handling Signals and Graceful Script Termination with trap

Learn to use the `trap` command in bash to intercept signals like Ctrl+C (SIGINT), allowing scripts to perform cleanup tasks and exit gracefully.

View Snippet →
BASH

Checking Multiple Network Port Availability on Localhost

A bash script to check the availability of a list of specified network ports on the local machine using `nc` (netcat), useful for diagnosing service issues.

View Snippet →
BASH

Automating Web Application Deployment via Rsync over SSH

Streamline web application deployments by securely synchronizing local files to a remote server using rsync over SSH, ensuring efficient updates and version control.

View Snippet →
BASH

Monitoring and Auto-Restarting a Web Service (e.g., Nginx)

Ensure continuous availability of critical web services like Nginx by scripting a bash monitor that periodically checks process status and automatically restarts it if found down.

View Snippet →
BASH

Extracting Specific Errors or Patterns from Web Server Logs

Efficiently analyze web server logs (e.g., Apache, Nginx) using bash to filter and extract critical error messages or custom patterns, aiding in quick debugging and issue identification.

View Snippet →
BASH

Automating Daily Database Backups for Web Applications

Secure your web application data by scheduling automatic daily database backups using bash scripts for MySQL or PostgreSQL, ensuring reliable data recovery and disaster preparedness.

View Snippet →