System Maintenance
Comprehensive system maintenance tool for Linux systems that automates routine maintenance tasks and system health monitoring.
System Maintenance Tool
A comprehensive system maintenance tool for Linux systems that automates routine maintenance tasks and system health monitoring.
Features
Automated Maintenance Tasks
Daily Tasks
- Package list updates
- Temporary file cleanup
- Log rotation
- Disk space checks
- Service status monitoring
Weekly Tasks
- Package cache cleanup
- Journal log cleanup
- System updates
- Weekly report generation
Monthly Tasks
- System upgrades
- Monthly report generation
- Comprehensive system health check
System Health Monitoring
- CPU usage monitoring
- Memory usage tracking
- Disk space monitoring
- Service status checks
- Disk I/O monitoring
- System resource alerts
Reporting
- HTML-formatted reports
- System information
- Resource usage statistics
- Service status overview
- Recent log entries
- Customizable report templates
Installation
Prerequisites
- Bash shell
- Root or sudo privileges
- Basic system utilities (tar, find, awk, etc.)
- Optional:
yq
for YAML processing
Installation Steps
Download the script from the Lambda Softworks Customer Portal:
- Log in to your Lambda Softworks Customer Portal account
- Navigate to the Files section
- Download the system-maintenance.sh script
Make the script executable:
chmod +x system-maintenance.sh
- Install dependencies:
# For Debian/Ubuntu sudo apt-get update sudo apt-get install -y bc sysstat # For RHEL/CentOS sudo yum install -y bc sysstat
- Create configuration file (optional):
sudo mkdir -p /etc/lambdasoftworks sudo cp system-maintenance.yml /etc/lambdasoftworks/
Usage
Basic Commands
- Run daily maintenance:
sudo ./system-maintenance.sh --daily
- Run weekly maintenance:
sudo ./system-maintenance.sh --weekly
- Run monthly maintenance:
sudo ./system-maintenance.sh --monthly
- Check system health:
sudo ./system-maintenance.sh --check-health
Command-Line Options
--daily
: Run daily maintenance tasks--weekly
: Run weekly maintenance tasks--monthly
: Run monthly maintenance tasks--check-health
: Check system health--config FILE
: Use custom configuration file--help
: Show help message
Configuration
Configuration File
Location: /etc/lambdasoftworks/system-maintenance.yml
Example configuration:
# Maintenance settings DISK_SPACE_THRESHOLD: 85 LOG_RETENTION_DAYS: 7 # Service monitoring MONITORED_SERVICES: - nginx - apache2 - mysql - postgresql - sshd # Alert thresholds ALERT_THRESHOLDS: cpu: 80 memory: 80 disk_io: 80
Logs and Data Storage
Log Files
- Main log:
/var/log/lambdasoftworks/system-maintenance.log
- Health check logs:
/var/log/lambdasoftworks/health.log
- Reports:
/var/log/lambdasoftworks/reports/
Temporary Files
- Temporary directory:
/tmp/lambdasoftworks/
Examples
Daily Maintenance
# Run daily maintenance tasks sudo ./system-maintenance.sh --daily # Check the maintenance log tail -f /var/log/lambdasoftworks/system-maintenance.log
Weekly Maintenance
# Run weekly maintenance tasks sudo ./system-maintenance.sh --weekly # View the weekly report firefox /var/log/lambdasoftworks/reports/weekly_report_$(date +%Y%m%d).html
Monthly Maintenance
# Run monthly maintenance tasks sudo ./system-maintenance.sh --monthly # View the monthly report firefox /var/log/lambdasoftworks/reports/monthly_report_$(date +%Y%m%d).html
Troubleshooting
Common Issues
Permission Errors
- Ensure the script is run with sudo
- Check directory permissions
- Verify user has necessary privileges
Service Monitoring Issues
- Verify service names in configuration
- Check systemd service status
- Review service logs
Report Generation Issues
- Check log directory permissions
- Verify HTML template access
- Check disk space
Debug Mode
To enable debug logging:
sudo DEBUG=1 ./system-maintenance.sh [OPTIONS]