Solved

Compress or move multiple files

Posted on 2006-06-18
7
1,043 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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