Skip to content

Bash scripts to maintain and optimize your development environment by cleaning up Git repositories and old log files.

License

Notifications You must be signed in to change notification settings

fabioboris/cleanup-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Cleanup Scripts

Bash scripts to maintain and optimize your development environment by cleaning up Git repositories and old log files.

Overview

This project provides two scripts to keep your development workspace clean and optimized:

  • Git Repository Optimization: Runs git gc on all repositories to reclaim disk space
  • Log File Cleanup: Removes old log files based on age criteria

Scripts

cleanup-git.sh

Recursively finds all Git repositories in a directory and optimizes them using git gc --aggressive.

cleanup-logs.sh

Removes old files from common log directories (log, logs, tmp and temp) based on modification time.

Installation

  1. Clone or download the scripts to your local machine:

    curl -O https://raw.githubusercontent.com/fabioboris/cleanup-scripts/refs/heads/main/cleanup-git.sh
    curl -O https://raw.githubusercontent.com/fabioboris/cleanup-scripts/refs/heads/main/cleanup-logs.sh
  2. Make them executable:

    chmod +x cleanup-git.sh cleanup-logs.sh
  3. Optional: Move to a directory in your PATH:

    sudo mv cleanup-*.sh /usr/local/bin/

Usage

Git Repository Cleanup

# Clean current directory
./cleanup-git.sh

# Clean specific directory
./cleanup-git.sh /path/to/projects

# Quiet mode (minimal output)
QUIET=true ./cleanup-git.sh /path/to/projects

Log File Cleanup

# Default cleanup (30 days)
./cleanup-logs.sh /path/to/projects

# Custom retention period
./cleanup-logs.sh -d 7 /path/to/projects

# Using environment variable
DAYS=15 ./cleanup-logs.sh /path/to/projects

# Show help
./cleanup-logs.sh -h

Requirements

  • Bash 4.0 or higher
  • GNU findutils (for -print0 and -delete options)
  • Git (for repository cleanup)
  • Unix-like system (Linux, macOS, WSL)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Test your changes thoroughly
  4. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Bash scripts to maintain and optimize your development environment by cleaning up Git repositories and old log files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages