Solved

Compress or move multiple files

Posted on 2006-06-18
7
1,046 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
Independent Software Vendors: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 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