{"id":15113690,"url":"https://github.com/nikoo-asadnejad/practical_bashscripts","last_synced_at":"2026-02-06T14:20:50.438Z","repository":{"id":256804694,"uuid":"856477727","full_name":"Nikoo-Asadnejad/Practical_BashScripts","owner":"Nikoo-Asadnejad","description":"This repository contains a collection of useful Bash scripts for Linux systems. Each script serves a specific purpose, ranging from system maintenance to monitoring and automation tasks. Below is a description of each script along with instructions on how to use them.","archived":false,"fork":false,"pushed_at":"2024-12-09T18:32:49.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T17:28:34.773Z","etag":null,"topics":["backup-script","backup-scripts","bash","bash-script","bash-scripting","disk-usage","disk-usage-analyzer","disk-usage-bot","linux","linux-shell","service-monitoring","shell","shell-script","shell-scripting","shell-scripts","status-checker","statuschecks","system-updater"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nikoo-Asadnejad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-12T16:33:43.000Z","updated_at":"2024-12-09T18:32:52.000Z","dependencies_parsed_at":"2024-09-13T05:48:52.705Z","dependency_job_id":"13bf2796-bbd7-47f8-87d7-807cb815c1f4","html_url":"https://github.com/Nikoo-Asadnejad/Practical_BashScripts","commit_stats":null,"previous_names":["nikoo-asadnejad/practical_bashscripts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikoo-Asadnejad%2FPractical_BashScripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikoo-Asadnejad%2FPractical_BashScripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikoo-Asadnejad%2FPractical_BashScripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikoo-Asadnejad%2FPractical_BashScripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nikoo-Asadnejad","download_url":"https://codeload.github.com/Nikoo-Asadnejad/Practical_BashScripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237784785,"owners_count":19365930,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup-script","backup-scripts","bash","bash-script","bash-scripting","disk-usage","disk-usage-analyzer","disk-usage-bot","linux","linux-shell","service-monitoring","shell","shell-script","shell-scripting","shell-scripts","status-checker","statuschecks","system-updater"],"created_at":"2024-09-26T01:22:18.328Z","updated_at":"2025-10-23T05:31:08.246Z","avatar_url":"https://github.com/Nikoo-Asadnejad.png","language":"Shell","readme":"\n# Bash Scripts Collection\n\nThis repository contains a collection of useful Bash scripts for Linux systems. Each script serves a specific purpose,\nranging from system maintenance to monitoring and automation tasks.\nBelow is a description of each script along with instructions on how to use them.\n\n## 🔧 Scripts Overview\n\n| Script Name                     | Purpose                                                                                      |\n|----------------------------------|----------------------------------------------------------------------------------------------|\n| `auto_git_commit.sh`            | Automatically commits staged changes with a standardized commit message.                     |\n| `backup.sh`                     | Backs up a specified directory into a dated folder.                                          |\n| `cpu_usage_alert.sh`            | Monitors CPU usage and sends an alert (e.g., via email) when usage exceeds a threshold.     |\n| `disk_usage_alert.sh`          | Checks disk usage and alerts if it passes a set limit.                                      |\n| `find_top_cpu_processes.sh`    | Lists processes consuming the most CPU.                                                      |\n| `find_top_memory_processes.sh` | Lists processes consuming the most memory.                                                   |\n| `install_docker.sh`            | Automates Docker installation on the host.                                                   |\n| `monitor_uptime.sh`            | Records system uptime periodically (ideal via cron).                                         |\n| `parse_log.sh`                 | Extracts and summarizes key data from log files.                                             |\n| `publish.sh` \u0026 `publish.ps1`   | Automates publishing tasks; supports both Bash and PowerShell environments.                  |\n| `resize_image.sh`              | Resizes images to predefined dimensions.                                                     |\n| `send_email.sh`                | Sends an email with attachments or notifications.                                           |\n| `service_status_check.sh`      | Monitors and restarts a service if it’s down.                                               |\n| `system_update_cleanup.sh`     | Updates the system and cleans up unused packages.                                           |\n| `top_largest_files.sh`         | Identifies and lists the largest files in a directory tree.                                 |\n| `website_health_check.sh`      | Tests website availability and alerts on downtime.                                          |\n\n---\n\n## Ensure executables:\n```bash\nchmod +x *.sh\n```\n\n## Run:\n```bash\n./script_name.sh\n```\n\n## 1. Backup Script (`backup.sh`)\n\nThis script creates a backup of a specified directory and stores it in a backup directory with the current date.\n\n- **Usage**: Update the `SOURCE_DIR` and `BACKUP_DIR` variables with the paths you want to back up and where you want to store the backup.\n- **Command**:\n  ```bash\n  ./backup.sh\n\n## 2. Disk Usage Alert (disk_usage_alert.sh)\n\nThis script checks the disk usage of the root partition and sends an alert email if it exceeds a specified threshold.\n- **Usage**: Set the THRESHOLD variable to the desired disk usage limit (in percentage) and update the EMAIL variable with the recipient’s email address.\n- **Command**:\n    ```bash\n   ./disk_usage_alert.sh\n\n## 3. System Update and Cleanup (system_update_cleanup.sh)\nThis script updates the system, cleans up unnecessary files, and removes unused packages to free up space.\n\n- **Usage**: Run the script with root privileges to update and clean the system.\n- **Command**:\n   ```bash\n   sudo ./system_update_cleanup.sh\n\n## 4. Monitor Server Uptime (monitor_uptime.sh)\nThis script logs the server uptime to a file. It can be set to run at regular intervals using a cron job.\n- **Usage**: Run the script to log the uptime periodically.\n- **Command**:\n  ```bash\n  ./monitor_uptime.sh\n\n## 6. Service Status Check (service_status_check.sh)\nThis script checks the status of a specified service and restarts it if it is not running.\n- **Usage**: Set the SERVICE variable to the service you want to monitor (e.g., nginx) and update the EMAIL variable with the recipient’s email address.\n- **Command**:\n   ```bash\n   .sudo ./service_status_check.sh\n\n\u003c/br\u003e\n\n-\tEnsure you have the required permissions to run the scripts (use chmod +x script_name.sh to make them executable).\n- Some scripts may require root privileges; use sudo where applicable.\n\n\n\u003c/br\u003e \n\n# Setting Up Bash Scripts as Cron Jobs :\n\nThis guide provides step-by-step instructions to add various Bash scripts as cron jobs on Linux systems.\nCron jobs allow you to schedule scripts to run automatically at specified intervals, making it easier to manage system maintenance, monitoring, and automation tasks.\n\n## Prerequisites\n\n- Ensure the scripts are executable:\n  ```bash\n  chmod +x /path/to/your_script.sh\n\n- Some scripts may require root privileges. Use sudo where applicable.\n\n- Add Scripts as Cron Jobs:\n\n  ```bash\n  crontab -e\n \n - Add entries to the crontab file in the following format:\n     \u003cp\u003e * * * * * /path/to/your_script.sh \u003c/p\u003e\n\nCron Scheduling Patterns: \n- \u003cp\u003e* * * * *: Runs every minute.\u003c/p\u003e\n-\t\u003cp\u003e0 * * * *: Runs at the start of every hour.\u003c/p\u003e\n-  \u003cp\u003e0 0 * * *: Runs daily at midnight.\u003c/p\u003e\n-\t\u003cp\u003e0 2 * * 0: Runs every Sunday at 2:00 AM.\u003c/p\u003e\n- \u003cp\u003e*/5 * * * *: Runs every 5 minutes.\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikoo-asadnejad%2Fpractical_bashscripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikoo-asadnejad%2Fpractical_bashscripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikoo-asadnejad%2Fpractical_bashscripts/lists"}