Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrxehmad/server-maintenance
shell script designed for weekly maintenance of a Debian server. The script performs essential tasks such as clearing various caches, removing unused Docker resources, cleaning APT cache, and managing log files
https://github.com/mrxehmad/server-maintenance
apt-cache automation cron-jobs debian docker-cleanup linux performance-optimization server-maintenance shell-script system-administration
Last synced: 29 days ago
JSON representation
shell script designed for weekly maintenance of a Debian server. The script performs essential tasks such as clearing various caches, removing unused Docker resources, cleaning APT cache, and managing log files
- Host: GitHub
- URL: https://github.com/mrxehmad/server-maintenance
- Owner: mrxehmad
- License: mit
- Created: 2024-06-13T13:30:49.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-13T03:57:32.000Z (4 months ago)
- Last Synced: 2024-11-10T15:12:16.615Z (3 months ago)
- Topics: apt-cache, automation, cron-jobs, debian, docker-cleanup, linux, performance-optimization, server-maintenance, shell-script, system-administration
- Language: Shell
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Debian Server Weekly Maintenance Script
This repository contains a shell script to perform weekly maintenance tasks on a Debian server. The script clears various caches, removes unused Docker data, cleans the APT cache, and performs other housekeeping tasks to ensure optimal server performance.
## Features
- Clear PageCache, dentries, and inodes
- Remove unused Docker images, containers, volumes, and networks
- Clean APT cache and remove unnecessary packages
- Clear systemd journal logs older than 7 days
- Clear temporary files in `/tmp` and `/var/tmp`## Usage
### Setup
1. **Clone the repository:**
```bash
git clone https://github.com/mrxehmad/Server-Maintenance.git
cd Server-Maintenance
```2. **Copy the script to `/usr/local/bin`:**
```bash
sudo cp weekly_maintenance.sh /usr/local/bin/
```3. **Make the script executable:**
```bash
sudo chmod +x /usr/local/bin/weekly_maintenance.sh
```4. **Set up the cron job:**
```bash
sudo crontab -e
```Add the following line to the crontab file to run the script every Sunday at 2 AM:
```bash
0 2 * * 0 /usr/local/bin/weekly_maintenance.sh > /var/log/weekly_maintenance.log 2>&1
```### Verify Cron Job
To verify that the cron job is set up correctly, you can list the current cron jobs:
```bash
sudo crontab -l
```### Manual Execution
You can manually run the script to test it:
```bash
sudo /usr/local/bin/weekly_maintenance.sh
```### Logging
The cron job redirects both stdout and stderr to a log file (`/var/log/weekly_maintenance.log`). Check this file to see the output of the script and troubleshoot any issues.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contributing
Contributions are welcome! Please open an issue or submit a pull request for any changes or improvements.
## Author
[mrxehmad](https://github.com/mrxehmad)