Bash script to delete old logs

From Cramsession
Revision as of 21:23, 12 December 2025 by Mflavell (talk | contribs) (Created page with " #!/bin/bash # Directory to clean up (change this to the target directory) TARGET_DIR="/path/to/your/directory" # Find and delete files starting with wd_index older than 7 days find "$TARGET_DIR" -type f -name "log_start_*" -mtime +7 -exec rm -f {} \; deletes files in TARGET_DIR that start with log_start older than 7 days")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
✍️ Verified Author: MflavellClick to view professional profile & credentials
#!/bin/bash
# Directory to clean up (change this to the target directory)
TARGET_DIR="/path/to/your/directory"
# Find and delete files starting with wd_index older than 7 days
find "$TARGET_DIR" -type f -name "log_start_*" -mtime +7 -exec rm -f {} \;


deletes files in TARGET_DIR that start with log_start older than 7 days