LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-27-2013, 05:02 AM   #1
contra04
LQ Newbie
 
Registered: Sep 2011
Location: London UK
Distribution: centos_fedora_DEbian
Posts: 18

Rep: Reputation: Disabled
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
 
Old 12-27-2013, 05:31 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Quote:
Originally Posted by contra04 View Post
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`*"
What is the bold part supposed to do in your opinion?

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 {} \;
- Find Files By Access, Modification Date / Time Under Linux or UNIX
- A Unix/Linux “find” Command Tutorial
 
Old 12-27-2013, 08:18 AM   #3
contra04
LQ Newbie
 
Registered: Sep 2011
Location: London UK
Distribution: centos_fedora_DEbian
Posts: 18

Original Poster
Rep: Reputation: Disabled
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to archive torrent file + the iso files , like the ova archive of virtual box jheengut Linux - Software 2 12-22-2013 06:04 PM
How to find files from today thomas2004ch Linux - Software 5 10-05-2010 06:25 AM
Archive files ust Linux - Newbie 3 03-06-2009 06:13 AM
Restrict exe files inside an archive files in samba paulreynand Linux - Networking 2 02-02-2006 05:07 AM


All times are GMT -5. The time now is 06:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration