Open weiT1993 opened 1 month ago
Here's a workaround.
#!/bin/bash
DIR_TO_CHECK="/path/to/directory"
SIZE_LIMIT=10485760
while true; do
find "$DIR_TO_CHECK" -type f -name '*.log' | while read -r FILE; do
FILE_SIZE=$(stat -f%z "$FILE")
if [ "$FILE_SIZE" -gt "$SIZE_LIMIT" ]; then
rm "$FILE"
echo "$(date '+%Y-%m-%d %H:%M:%S') - Deleted $FILE (size: $FILE_SIZE bytes)" >> /path/to/watch_log_files.log
fi
done
# Sleep for 10 seconds before checking again
sleep 10
done
2. Give script permissions: `chmod +x /path/to/watch_log_files.sh`
3. Create a LaunchAgent plist file in `~/Library/LaunchAgents/`, for example, `com.example.watch_log_files.plist`.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4. Launch it via `launchctl load ~/Library/LaunchAgents/com.example.watch_log_files.plist`
This is a question about what exists already. Please ask on the mailing list as the issue tracker is for bugs and validated/well-defined feature requests.
See
When I keep Unison running for a long time, the log files could become multiple GBs large. Is there a feature to automatically rewrite the logs when they become too large?