Ai Chat

Dynamic Log Rotation and Compression Script

log management automation shell scripting system administration
Prompt
Design a robust Bash script that automatically rotates and compresses log files across multiple directories, with configurable retention policies. The script should handle different log formats, support multiple compression algorithms (gzip, bzip2), and provide detailed logging of its own operations. Implement error handling to manage scenarios like insufficient disk space, permission issues, and large file volumes. Include a mechanism to send email notifications or trigger alerts if log rotation fails or encounters critical errors.
Sign in to see the full prompt and use it directly
Sign In to Unlock
Use This Prompt
0 uses
10 views
Pro
Bash
General
Mar 3, 2026

How to Use This Prompt

1
Copy the prompt Click "Copy" or "Use This Prompt" above
2
Customize it Replace any placeholders with your own details
3
Generate Paste into Ai Chat and hit generate
Use Cases
  • Automatically manage server logs for better performance.
  • Reduce disk usage by compressing old log files.
  • Schedule log rotations based on application needs.
Tips for Best Results
  • Set appropriate thresholds for log size to trigger rotation.
  • Regularly monitor log file sizes to adjust settings.
  • Test the script in a staging environment before production.

Frequently Asked Questions

What is dynamic log rotation?
Dynamic log rotation automatically manages log files based on size or time.
How does compression work in this script?
The script compresses old log files to save disk space.
Can I customize the rotation schedule?
Yes, you can set specific intervals for log rotation.
Link copied!