Archive Files that are not already .gz and not today
Morning people, I am trying to use the script sxample on the syslog-ng webpage to rotate and zip my logs.
I am using: /usr/bin/find /var/log/cisco ! -name "*.gz" -type f ! -path "*`/bin/date +%Y/%m/%d`*" -exec /usr/bin/gzip {} \; But it doesnt seem to ignore today's date? When I run: /usr/bin/find /var/log/cisco ! -name "*.gz" -type f ! -path "*`/bin/date +%Y/%m/%d`*" It correctly "!"'s doesn't not find the gzip files, but it still finds todays date? I fixed this about a year ago, but for the life of me cannot remember how I did it. Any help would be greatly appreciated |
Quote:
The date part results in 2013/12/27, are there any sub-directories that contain that string? I guessing you want to use -mtime and possibly -daystart: Code:
/usr/bin/find /var/log/cisco -type f ! -name "*.gz" -daystart -mtime +1 -exec /usr/bin/gzip {} \; - A Unix/Linux “find” Command Tutorial |
Ahh yes your right - the filenames are /deivename/devicename%date%
so this works: #!/bin/bash PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/etc/syslog-ng/ find /var/log/cisco ! -name "*.gz" -type f ! -name "*`date +%Y%m%d`*" -exec gzip -f {} \; as I removed the / / / from the date seems to work ! Thanks |
All times are GMT -5. The time now is 10:23 PM. |