Last active
May 5, 2024 09:09
-
-
Save yazanmonshed/a0be6cc7a565c8f5fa06c5593d9b7d6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set the path to the Laravel logs directory | |
LOG_DIR=/path/to/laravel/logs | |
# Set the number of days to keep log files | |
DAYS_TO_KEEP=7 | |
# Find all Laravel log files older than $DAYS_TO_KEEP days and delete them | |
find "$LOG_DIR" -name "*.log" -type f -mtime +$DAYS_TO_KEEP -exec rm {} \; | |
# Output a message indicating the number of files deleted | |
echo "Deleted $(find "$LOG_DIR" -name "*.log" -type f -mtime +$DAYS_TO_KEEP | wc -l) log files older than $DAYS_TO_KEEP days." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment