π§Ή LogSweep: Automated Log & Temp File Cleanup π
Automate the cleanup of old log and temp files to keep your system optimized and free from clutter.
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.
- β 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.
- π About the Project
- π Features
- π οΈ Project Structure
- β‘ Installation & Usage
- π Automate with Cron Jobs
- π Future Enhancements
- π‘ Contributing
- π© Contact
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.
- β 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!
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
-
Clone the Repository
git clone https://github.com/yourusername/auto-log-cleanup.git cd auto-log-cleanup -
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
- Edit the configuration file:
-
Make the Script Executable
chmod +x scripts/cleanup.sh
-
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.
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! π
- πΉ Email notifications after each cleanup.
- πΉ Store logs in a database for analytics.
- πΉ User-friendly CLI menu for configuring the script.
π₯ Want to improve this project? Feel free to:
- β Fork the repository
- β Submit a pull request
- β Report bugs or request features
- πΉ GitHub: [https://github.com/Kirankumarvel/LogSweep]
- πΉ LinkedIn: [https://www.linkedin.com/in/kirankumarvel/]
π€ Letβs build efficient automation together! π