Sponsored Content
Top Forums Shell Programming and Scripting Need help to tar and gzip files per date Post 302581260 by vishal7 on Monday 12th of December 2011 02:13:14 PM
Old 12-12-2011
Need help to tar and gzip files per date

hi,

I have multiple files created per date every day. I want to be able to tar all the files older than 7 days into a single file and then gzip that tarred file and move it to a separate partition. Then delete the actual files.

Eg - "ls -l" shows Dec 8 has 6-8 files created. I want to tar them into a single file Date.tar and gzip them and move it to a separate partition.

The platform I run on does not have perl and its only shell scripting and I am not very good at it.

Please advise.

Thank you, V

Code:
-rw-rw-r--    1 root     root      1116305 Dec  8 00:13 2011-12-08_001334.log
-rw-rw-r--    1 root     root           80 Dec  3 00:58 2011-12-08_001334.logaccount_ptr
-rw-rw-r--    1 root     root        46580 Dec  8 00:13 2011-12-08_001334.loginitial_ptr
-rw-rw-r--    1 root     root        46616 Dec  8 00:13 2011-12-08_001334.logptr
-rw-rw-r--    1 root     root       295855 Dec  8 23:59 2011-12-08_235901.log
-rw-rw-r--    1 root     root           80 Dec  8 00:13 2011-12-08_235901.logaccount_ptr
-rw-rw-r--    1 root     root        12012 Dec  8 23:58 2011-12-08_235901.loginitial_ptr
-rw-rw-r--    1 root     root        12012 Dec  8 23:58 2011-12-08_235901.logptr
-rw-rw-r--    1 root     root       291721 Dec  9 23:59 2011-12-09_235916.log
-rw-rw-r--    1 root     root           80 Dec  8 23:59 2011-12-09_235916.logaccount_ptr
-rw-rw-r--    1 root     root        11892 Dec  9 23:59 2011-12-09_235916.loginitial_ptr
-rw-rw-r--    1 root     root        11892 Dec  9 23:59 2011-12-09_235916.logptr
-rw-rw-r--    1 root     root       280519 Dec 10 23:59 2011-12-10_235900.log
-rw-rw-r--    1 root     root           80 Dec  9 23:59 2011-12-10_235900.logaccount_ptr
-rw-rw-r--    1 root     root        11420 Dec 10 23:58 2011-12-10_235900.loginitial_ptr
-rw-rw-r--    1 root     root        11420 Dec 10 23:58 2011-12-10_235900.logptr
-rw-rw-r--    1 root     root       274462 Dec 11 23:59 2011-12-11_235900.log
-rw-rw-r--    1 root     root           80 Dec 10 23:59 2011-12-11_235900.logaccount_ptr
-rw-rw-r--    1 root     root        11184 Dec 11 23:58 2011-12-11_235900.loginitial_ptr
-rw-rw-r--    1 root     root        11184 Dec 11 23:58 2011-12-11_235900.logptr

---------- Post updated at 11:13 AM ---------- Previous update was at 10:45 AM ----------

I can use the command to list all log files older than 7 days
Code:
find / -mtime +90 -exec ls -l {} \; -name "*.log*"

Now the challenge is to create a tar of the multiple files per day date.tar and then gzip to date.tar.gz

Last edited by methyl; 12-12-2011 at 02:56 PM.. Reason: please use code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Combine tar and gzip together?

Hello I just wandering, instead to doing "tar cvf foo.tar * " and then gzip foo.tar , can't it be combined to one command ? (1 Reply)
Discussion started by: umen
1 Replies

2. UNIX for Dummies Questions & Answers

can i tar and gzip in one liner ?

hello can i combine this 2 commands in one liner command? (1 Reply)
Discussion started by: umen
1 Replies

3. UNIX for Dummies Questions & Answers

TAR and GZIP help

Hi, There are 700 .pdf files in a certain directory on the server and I need to TAR them first and then compress them using GZIP to free up the space. The combined size of the .pdf files is 3gb. However, there is only 1gb of free space on the server. So as you can see when I try to TAR these... (3 Replies)
Discussion started by: VandeMatram
3 Replies

4. UNIX for Advanced & Expert Users

tar/gzip/gz...which one to use?

P0251WLADC.svm_wl1 > /svm_wl1/billing/data/server/archive/ALLEVT $ du -k FEB2006 22050224 FEB2006 As you can see,i have a folder called "FEB2006" which is around 22 GB. i guess zip or compress wont work...( i don know how do we compress a folder) i wished to use ""tar" ( i suppose... (5 Replies)
Discussion started by: abhijeetkul
5 Replies

5. UNIX for Dummies Questions & Answers

tar and gzip

Hi, I would like to have a combined gzip and tar that will compress and create multiple output tar.gz files. I want to have multiple files output because i cannot create an archive because there is no more space on my harddisk. I cannot transfer it locally because of slow connection. I want to... (3 Replies)
Discussion started by: tungaw2004
3 Replies

6. Shell Programming and Scripting

tar + gzip + split together

Hi All I need guidance on this requirement . We have a directory structure which has data of approx 100 GB We need to tar the structure then zip it and create different files of not more than 10 GB A separate tar file then a .gz should not be created , on the fly a script is needed... (7 Replies)
Discussion started by: aamir1234
7 Replies

7. Shell Programming and Scripting

tar files by date

Hi, I have a solaris 10, I would like to tar log files by date, or by range of hours into one tar file. All I coud do is by name (very simple...:cool:). (4 Replies)
Discussion started by: pointer
4 Replies

8. UNIX for Dummies Questions & Answers

Create Tar and GZip files under Unix

Hi All I have 2 tar files and inside a Gzip file (actually its folder) that i got from a Unix user to check the code for him and find some problem. I decompress the Tar file and use 7-ZIP to open the Gzip file and Extract all folders and files. I found the code problem and change it but now when... (1 Reply)
Discussion started by: giladboker
1 Replies

9. Shell Programming and Scripting

tar and gzip files

Hi Guys, I am using RHEL5 and Solaris 9 & 10. I want to tar and gzip my files then remove them after a successful tar command... Lets say I have files with extension .arc then I want to tar and gzip these files. After successful tar command I want to remove all these files (i.e .arc). ... (3 Replies)
Discussion started by: Phuti
3 Replies

10. Red Hat

Tar with particular date files

I need to find out only Jun 10 created and modified file with tar command ,, I am using Linux red hat x86_64 GNU/Linux. ls -lrt -rw-r--r-- 1 nova nova 2757 Jun 7 11:00 feed.ctl -rwxrwxr-x 1 nova nova 457 Jun 7 11:00 acc_feed.csh -rwxr-xr-x 1 nova nova 473 Jun 7 12:11... (2 Replies)
Discussion started by: balajikalai
2 Replies
SYSSTAT(5)							Linux User's Manual							SYSSTAT(5)

NAME
sysstat - sysstat configuration file. DESCRIPTION
This file is read by sa1(8) and sa2(8) shell scripts from the sysstat's set of tools. It consists of a sequence of shell variable assign- ments used to configure sysstat logging. The variables and their meanings are: HISTORY The number of days during which a daily data file or a report should be kept. Data files or reports older than this number of days will be removed by the sa2(8) shell script. COMPRESSAFTER Number of days after which daily data files are to be compressed, either by gzip or bzip2. SADC_OPTIONS Options that should be passed to sadc(8). With these options (see sadc(8) manual page), you can select some additional data which are going to be saved in daily data files. These options are used only when a new data file is created. They will be ignored with an already existing one. FILES
/etc/sysstat/sysstat AUTHOR
Sebastien Godard (sysstat <at> orange.fr) SEE ALSO
sadc(8), sa1(8), sa2(8) http://pagesperso-orange.fr/sebastien.godard/ Linux SEPTEMBER 2010 SYSSTAT(5)
All times are GMT -4. The time now is 11:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy