Skip to content

Kirankumarvel/LogSweep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LogSweep

🧹 LogSweep: Automated Log & Temp File Cleanup πŸš€
Automate the cleanup of old log and temp files to keep your system optimized and free from clutter.

πŸ“Œ About LogSweep

LogSweep is a lightweight and efficient automation tool designed to delete old log and temporary files, preventing disk space issues and keeping your system clutter-free. It can be scheduled via cron jobs for full automation.

πŸš€ Features

  • βœ… Automatically deletes log & temp files older than a set number of days.
  • βœ… Configurable paths & retention period via a simple config file.
  • βœ… Keeps a log of all cleanup actions.
  • βœ… Lightweight & fast execution.
  • βœ… Works with cron jobs for full automation.

πŸ“œ Table of Contents

  • πŸ“Œ About the Project
  • πŸš€ Features
  • πŸ› οΈ Project Structure
  • ⚑ Installation & Usage
  • πŸ“… Automate with Cron Jobs
  • πŸ“œ Future Enhancements
  • πŸ’‘ Contributing
  • πŸ“© Contact

πŸ“Œ About the Project

This Bash script automatically removes log and temporary files older than X days from a configured directory. It helps prevent disk space issues and improves system performance by deleting unnecessary files regularly.

πŸš€ Features

  • βœ… Deletes log and temporary files older than a specified number of days.
  • βœ… Uses a configuration file for easy customization.
  • βœ… Keeps a log file of all cleanup actions.
  • βœ… Can be scheduled with a cron job for full automation.
  • βœ… Lightweight & efficient – runs in seconds!

πŸ› οΈ Project Structure

auto-log-cleanup/
β”œβ”€β”€ scripts/
β”‚   └── cleanup.sh             # Main script to delete old logs/temp files
β”œβ”€β”€ config/
β”‚   └── config.env             # Configuration file (threshold days, directories)
β”œβ”€β”€ logs/
β”‚   └── cleanup.log            # Stores cleanup history
β”œβ”€β”€ .gitignore                 # Ignores sensitive files
β”œβ”€β”€ README.md                  # Project documentation
└── cronjob.txt                # Cron job setup guide

⚑ Installation & Usage

  1. Clone the Repository

    git clone https://github.com/yourusername/auto-log-cleanup.git
    cd auto-log-cleanup
  2. Configure Cleanup Settings

    • Edit the configuration file:
      nano config/config.env
    • Modify these values:
      LOG_DIR="/var/log/myapp"        # Directory for log files
      TEMP_DIR="/tmp/myapp"           # Directory for temp files
      DAYS_OLD=7                      # Delete files older than 7 days
  3. Make the Script Executable

    chmod +x scripts/cleanup.sh
  4. Run the Script Manually

    ./scripts/cleanup.sh

    This will delete all log/temp files older than 7 days and save the action in logs/cleanup.log.

πŸ“… Automate with Cron Jobs

To run the script automatically every day at midnight, schedule it using cron:

  • Open the cron job editor:
    crontab -e
  • Add this line at the bottom:
    0 0 * * * /bin/bash /path/to/auto-log-cleanup/scripts/cleanup.sh
  • Save & exit. Your script will now run daily! πŸŽ‰

πŸ“œ Future Enhancements

  • πŸ”Ή Email notifications after each cleanup.
  • πŸ”Ή Store logs in a database for analytics.
  • πŸ”Ή User-friendly CLI menu for configuring the script.

πŸ’‘ Contributing

πŸ”₯ Want to improve this project? Feel free to:

  • βœ… Fork the repository
  • βœ… Submit a pull request
  • βœ… Report bugs or request features

πŸ“© Contact

🀝 Let’s build efficient automation together! πŸš€

About

🧹 LogSweep: Automated Log & Temp File Cleanup πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages