This repository contains a collection of general-purpose utility bash scripts. These scripts are designed to automate various routine tasks. They are typically scheduled via cron jobs to ensure consistent and hands-free execution. The goal of this repo is to centralize and version-control personal automation tools for easier maintenance and reuse across systems.
To get started with the project repository, follow the steps below:
First, clone the repository to your ~/bin directory (or any preferred location):
git clone https://github.com/busycaesar/linux-bin-scripts.git ~/binFor automating the execution of scripts, you can schedule them using cron jobs. To set up a cron job, open the crontab editor:
crontab -eThen, add a line to run the script you want to automate at the specified time. For example, to run the backup script every day at midnight:
0 0 * * * /bin/bash ~/bin/backupYou can set the cron job to run any script from the repository by adjusting the script name and schedule as needed.
Now, you can run the scripts manually or via scheduled cron jobs. To run a script manually, simply execute it with:
~/bin/script_name-
process_dir_list: This script takes two inputs: thepath to another scriptand afile containing a list of directory paths. It reads each directory path from the list (ignoring empty lines and comments), and for each valid entry, it executes the provided script with the directory path as an argument. -
To use this functionality, you need to create a
.env.configfile the contains the following configuration variables.# Absolute path to the directory where the backup bundles will be stored. DEFAULT_OUTPUT="path/to/dir" # Absolute path to the directory on an external drive where the backup bundles will be transferred from DEFAULT_OUTPUT. EXTERNAL_DRIVE_LOCATION="path/to/external/drive"
-
commit_and_bundle: This script accepts a project directory (and optionally, an output directory) as input. It commits any uncommitted changes in the directory, creates a Git bundle file, containing the entire repository history, and moves the bundle to the specified output directory (defaulting to~/backup). It is intended to ensure that important system directories are under version control, and bundled into portable .bundle files. -
backup: The purpose of this script is to automate the process of creating backup bundles of specified directories and moving them to an external drive. It first calls thecommit_and_bundlescript to create bundles of directories listed in a file and stores them in the~/backupdirectory. Then, it copies all the generated bundles to an external drive for safe storage.
-
-
-
delete_temp_files: This script is designed to delete all files within a specified directory while leaving the directory structure intact. It takes a directory path as input, and then removes all files inside that directory. This script helps in cleaning up directories without removing the directories themselves. -
clean_temp_dirs: This script automates the process of cleaning up temporary files in multiple directories. It calls thedelete_temp_filesscript to delete files from a list of directories specified in a directory list file. This is useful for managing and cleaning temporary or unnecessary files across multiple locations in one go.
-