Solved

Compress or move multiple files

Posted on 2006-06-18
7
1,047 Views
Last Modified: 2013-12-26
what is the compress syntax for compressing multiple files for a specific date?

Archive log space is filling up and I need to compress and move the files.  Syntax can be either compress or move?

URGENT
0
Comment
Question by:mjimison1956
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16930283
find /path/to/files -mtime 42 -exec gzip {} \;
# compresses files older than 42 days
0
 

Author Comment

by:mjimison1956
ID: 16930344
I am receiving error that my Unix does not recognize -mtime.

I changed directories to the location of the archive logs and typed in

-mtime 42 -exec gzip {}\;     when I typed this in it went to a > prompt   and nothing happened.

Any ideas?  I did a man on mtime.... not recognized.

Mike
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 16930375
> -mtime 42 -exec gzip {}\;     when I typed this in it went to a > prompt   and nothing happened.
what should this do?

> ..  my Unix does not recognize -mtime.
Please read
  man find

which Unix do you have? there should be at least one option for find similar to -mtime
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mjimison1956
ID: 16930450
HP-UX B.11.11 U(64) is the OS

here is what I found on the man find reference time:

-mtime n                 True if the file modification time subtracted
                         from the initialization time is n-1 to n
                         multiples of 24 h.  The initialization time
                         shall be a time between the invocation of the
                         find utility and the first access by that
                         invocation of the find utility to any file
                         specified in its path operands.

-ctime n                 True if the time of last change of file
                         status information subtracted from the
                         initialization time is n-1 to n multiples of
                         24 h.  The initialization time shall be a
                         time between the invocation of the find
                         utility and the first access by that
                         invocation of the find utility to any file
                         specified by its path operands.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 16931232
You were missing the find statement!

Read again, should be

find /path/to/die -mtime 42 -exec gzip {} \;

Note that the space after {} is important.
0
 
LVL 38

Expert Comment

by:yuzh
ID: 16931391
For old then 42 days you should use:
  +42
  42 - means exactly 42 day
  -42  less than 42 day

  man find

  I would put all the file in tar ball then  gzip the tar ball

  tar cf /path-to/backup.tar `find /path/to/die -mtime +42`
  gzip /path-to/backup.tar

  If you have GNU tar installed in your system, you can do:
  (assume you installed it in /usr/local/bin):

    /usr/local/bin/tar -zcvf /path-to/backup.tar.gz `find /path/to/die -mtime +42`

 You can download GUN tar binary package for HP-UX from:
  http://hpux.cs.utah.edu/hppd/hpux/Gnu/tar-1.15.1/
  (remember to install all the dependencie)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16933818
we have some housekeeping scripts, Ive setup a config file whereby u can select what directory and what action to do in a number of days
e.g. archive all files in directory /fred that are over 15days old

basically the command built up is how ahoffman has described.

But the answer supplied by ahoffman works and works fine. If u use that correctly and put in your parameters, you will see it works.

The only additions I have to this is

1. I only check for files. If I have data directories that need archiving, I don't archive the directory, just the files inside it
2. I use -f on gzip to force the compression otherwise, if u try to compress to a file that already exists, then it won't do it

e.g.

find /fred/data -mtime +15 -type f -name 'fred*.log'  -exec gzip -f {} \;



u say u want to compress and move the files, is that right?
I guess u can then find file types of .gz and exec mv
after u run the first find


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question