Solved

Compress or move multiple files

Posted on 2006-06-18
7
1,040 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 85
Expand LInux Boot partition remotly 3 78
isEverywhere  challenge 19 64
matchUp  challenge 6 48
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now