coding

Bash Script for Log Rotation

Create a Bash script to automate log file rotation

The Prompt
Write a Bash script that rotates log files in [LOG_DIRECTORY] daily, compresses old logs, and deletes logs older than [RETENTION_DAYS]. Replace [LOG_DIRECTORY] and [RETENTION_DAYS] with your specific values.

Get 10 fresh prompts weekly — free, no spam.

When to use this

For managing server logs and preventing disk space issues.

Pro tips

  • Add error handling for missing directories.
  • Include email notifications for failed rotations.

More coding prompts