Premium
BASH Snippets.

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

BASH

Automating Website Backup to Remote Server

Learn to create a robust Bash script for backing up website files and databases, then securely transfer them to a remote server using tar and rsync.

View Snippet →
BASH

Automated Static Website Deployment with SCP/RSYNC

Learn how to write a Bash script for quickly deploying static website files to a remote web server using secure copy (scp) or rsync for efficiency.

View Snippet →
BASH

Archive and Clean Up Old Log Files

Implement a Bash script to manage server log files by archiving old logs, compressing them, and deleting original files to save disk space.

View Snippet →
BASH

Start Multiple Background Services for Development

Create a convenient Bash script to concurrently start and manage multiple development services, like a local server and a watcher, in the background.

View Snippet →
BASH

Create Timestamped Tar.gz Backup of a Directory

Learn how to create compressed, timestamped tar.gz archives of any directory, perfect for web application backups and versioning.

View Snippet →
BASH

Wait for a Specific Port to Become Available

Ensure dependent services start in the correct order by pausing script execution until a specified network port is listening, preventing connection errors.

View Snippet →
BASH

Load and Export .env Variables in Bash

A bash script to parse a `.env` file and export its key-value pairs as environment variables, commonly used for web application configuration.

View Snippet →
BASH

Nginx Service Control and Status Check Script

A bash script to check the status, start, stop, or restart the Nginx web server, useful for web server management and deployment workflows.

View Snippet →
BASH

Automate Git Clone and Dependency Install

A bash script to automate cloning a Git repository and installing common project dependencies (npm, Composer), ideal for new project setups.

View Snippet →
BASH

Parse Command Line Options with `getopts`

A robust bash script demonstrating how to parse command-line arguments and options using `getopts` for flexible script execution.

View Snippet →
BASH

HTTP Service Health Check Script

A bash script to perform a basic HTTP health check on a web service, useful for monitoring, deployment validation, and automated checks.

View Snippet →
BASH

Automate Log File Cleanup by Age

Learn to create a bash script for automatically cleaning up old log files from a specified directory, preventing disk space exhaustion and maintaining server health.

View Snippet →