Prompt for a log cleanup script you can trust

Vibe codingEasy20 min

Your task

Your app writes logs to /var/log/myapp, and the disk keeps filling up. You want a Bash script, run daily by cron, that deletes log files older than 30 days. You are about to ask an AI assistant to write it.

Write the prompt you would give the assistant.

What you know:

  • the folder holds .log files and gzipped rotations such as app.log.3.gz
  • a config/ subfolder inside it must never be touched
  • the script runs as root
  • the path will come from an environment variable, LOG_DIR

Then, in a few sentences: which constraint matters most, and why?