Premium
BASH Snippets.

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

BASH

Monitor Website Availability with Bash

A Bash script to periodically check if a website is online and notify if it's down, useful for site reliability and basic health checks.

View Snippet →
BASH

Create Timestamped Backups of Directories

A Bash script to automatically create compressed, timestamped backups of a specified directory, essential for data recovery and versioning.

View Snippet →
BASH

Parse and Extract Data from JSON with `jq`

Learn how to use `jq` in Bash to efficiently parse JSON output from APIs or files, extracting specific fields and transforming data for scripting.

View Snippet →
BASH

Check and Restart a Linux Service or Process

A Bash script to verify if a specified process or service is running and, if not, restart it, ensuring continuous application availability.

View Snippet →
BASH

Check SSL Certificate Expiry and Send Notification

Monitor the expiration date of an SSL certificate for a given domain and send a notification if it's nearing expiry, preventing service interruptions.

View Snippet →
BASH

Find and Delete Old Files by Age and Extension

Recursively locate and remove files older than a specified number of days, filtered by file extension, to help manage disk space on web servers.

View Snippet →
BASH

Synchronize Local Files to Remote Server with rsync

Efficiently deploy and synchronize local website files to a remote server using rsync, transferring only changed files and excluding specific patterns for faster updates.

View Snippet →
BASH

Basic Web Service Health Check with cURL

Perform a simple health check on a web service endpoint using cURL, verifying its HTTP status code and response time, useful for monitoring.

View Snippet →
BASH

Automate Git Repository Backup

Create a timestamped, compressed backup of a local Git repository, ideal for safeguarding project history or migrating repositories.

View Snippet →
BASH

Monitor and Auto-Restart Systemd Service

A robust bash script to check the status of a systemd service (e.g., Nginx, Apache) and automatically restart it if it's inactive or failed, ensuring service uptime.

View Snippet →
BASH

Robust Command Line Argument Parsing

Master parsing command-line options and arguments in bash scripts using `getopts` for creating flexible and user-friendly utilities with short flags.

View Snippet →
BASH

Automate Static Website Deployment via SCP

Streamline static website deployment to a remote server using a simple bash script that utilizes SCP for efficient and secure file transfer.

View Snippet →