Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Help me with find and tar on postrotate script Post 302578595 by laxyblack on Friday 2nd of December 2011 02:28:10 AM
Old 12-02-2011
Help me with find and tar on postrotate script

Hi,

My requirements are
  1. I wanted to move my daily logs to /appl/logs/old folder
  2. Archive and compress all 10 days older log files under /appl/logs/old in YYYYMMDD format file
  3. To remove any 60 days older log files from /appl/logs/old

I tried this scenario with logrotate utility
Code:
/appl/logs/SIN* {
daily
rotate 1
nocreate
nocompress
olddir /appl/logs/old
nodateext
missingok
notifempty
postrotate
export NEW=/appl/logs/old
cd $NEW/old
/usr/bin/find $NEW -name 'SIN*' -type f -mtime +10 | awk -F "/" '{print $NF}' > status
tar --remove-files -cvzf $NEW/`date '+%Y%m%d'.tgz` -T $NEW/status
#/usr/bin/find $NEW/old -name 'SIN*' -type f -mtime +10 -exec rm -f {} \;
/usr/bin/find $NEW/old/archive -mtime +60 -exec rm -f {} \;
endscript

Problem i am facing here is , when I run it with remove option or removing by using commented find command
its archive only one file

And when i execute manually the above command , it is running as per expectation

Please help me on this issue , suggest me some alternate solution

Thanks
Moderator's Comments:
Mod Comment Please use code tags!

Last edited by laxyblack; 12-02-2011 at 05:49 AM.. Reason: please use code tags for your code and data next time, thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to use the command Tar to find a file

Hello, I am just using the command Tar to find if a file was backuped on my tape. Can you help me with that command. I am using the command : tar -tvf /dev/rmt/4m /kcc_dms/AC7/c15a* > toto.txt to find all files c15a* in these subdirectories on my tape. But it doesn't work correctly. Can... (2 Replies)
Discussion started by: steiner
2 Replies

2. UNIX for Dummies Questions & Answers

Problem with find and tar

When I am doing the first command the result shows all the files, links, directories except the ones that contain the word logs find . -type f -o -type l -o -type d | grep -v logs But when I am trying to do this even the logs are getting tarred tar -cvf fdtvision.tar `find . -type f -o -type l... (2 Replies)
Discussion started by: venu_nbk
2 Replies

3. Shell Programming and Scripting

'find' and 'tar' combination

I'm trying to tar the files I get from the 'find' command result. However I can't make it run successfuly? This is for our archiving process. Here is my script: find /mnt/LOGS -mtime -10 -name "TUXLOG.*" -exec tar -cvf /mnt/LOGS/combine.tar {} \; Im not sure why it is not working or it is... (2 Replies)
Discussion started by: kharen11
2 Replies

4. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

5. UNIX for Dummies Questions & Answers

find a corrupt tar file

Hey there I am just looking for a way to find a corrupt tar file. I want to write a script to help sift through the 1000's of tar files we go through daily and move any corrupt ones to a different directory structure. Is there an easy way to do this. (4 Replies)
Discussion started by: car2nst2006
4 Replies

6. Red Hat

error running postrotate script

Hi, I am getiing emails from cron.daily with subject: Cron root@vsftp run-parts /etc/cron.daily /etc/cron.daily/logrotate: /sbin/killall -HUP radiusd : line 1: /sbin/killall: No such file or directory error: error running postrotate script for /var/log/vsftpd/logfile the... (6 Replies)
Discussion started by: renuka
6 Replies

7. Shell Programming and Scripting

Will the scope be there in logrotate after postrotate directive...?

Hi, Please check the below code...:wall: if ; then echo "/var/log/AAA/BBB/xxx_*.log /var/log/AAA/BBB/yyy_*.log {" >> /etc/logrotate.conf echo " weekly" >> /etc/logrotate.conf echo " rotate 10" >> /etc/logrotate.conf... (2 Replies)
Discussion started by: Dedeepthi
2 Replies

8. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

9. Shell Programming and Scripting

Find and Tar a Folder

Hi all, I have created a function that looks for a folder in a particular directory, checks the date it was last modified and if its old then compress it. This works fine for files using gzip. However for folders I had to use tar. This is my function: compressOldFolder() { # $1 is... (10 Replies)
Discussion started by: TasosARISFC
10 Replies

10. UNIX for Beginners Questions & Answers

Tar command generation with Find

Hello, I'm trying to generate a TAR command and fill it with the result of a Find command. What I did is not elegant and I'm sure that it can be in a different way to be faster. I need to Find all files with an extension to ".sf". If a file is found, I need to replace the extension ".sf" to... (11 Replies)
Discussion started by: royinfo.alain
11 Replies
SCANLOGS(8)						      System Manager's Manual						       SCANLOGS(8)

NAME
scanlogs - summarize INN log files. SYNOPSIS
scanlogs [ norotate ] [ nonn ] DESCRIPTION
Scanlogs summarizes the information recorded in the INN log files (see newslog(5)). By default, it also rotates and cleans out the logs. It is normally invoked by the news.daily(8) script. KEYWORDS
The following keywords are accepted: norotate Using this keyword disables the rotating and cleaning aspect of the log processing: the logs files are only scanned for information and no contents are altered. nonn Normally the nn log file is scanned and rotated. Using this keyword disables this function. If scanlogs is invoked more than once a day, the ``norotate'' keyword should be used to prevent premature log cleaning. HISTORY
Written by Landon Curt Noll <chongo@toad.com> and Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.1, dated 1996/10/29. SEE ALSO
innd(8) newslog(5), news.daily(8), nnrpd(8). SCANLOGS(8)
All times are GMT -4. The time now is 09:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy