Bird
0
0

To automate cleanup of log files older than 7 days daily, which command is best?

hard📝 Application Q9 of 15
Linux CLI - File and Directory Operations
To automate cleanup of log files older than 7 days daily, which command is best?
Afind /var/log -type f -mtime +7 -delete
Brm /var/log/*.log
Ccp /var/log/*.log /backup/
Dls /var/log | grep '.log'
Step-by-Step Solution
Solution:
  1. Step 1: Understand find command with mtime

    find with -mtime +7 finds files older than 7 days.
  2. Step 2: Use -delete to remove those files automatically

    This command deletes old log files safely and efficiently.
  3. Final Answer:

    find /var/log -type f -mtime +7 -delete -> Option A
  4. Quick Check:

    Automate old file deletion = B [OK]
Quick Trick: Use find with -mtime and -delete for cleanup [OK]
Common Mistakes:
  • Using rm without date filter
  • Copying instead of deleting
  • Listing files instead of deleting

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes