Help me with find and tar on postrotate script

Trivia Category: Science: Mathematics
Difficulty: Hard
L'Hôpital was the mathematician who created the homonymous rule that uses derivatives to evaluate limits with indeterminations.
True or False?

Thread Tools Search this Thread
# 1  
Help me with find and tar on postrotate script


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
/appl/logs/SIN* {
rotate 1
olddir /appl/logs/old
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 {} \;

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

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
# 2  
I am not sure you can separate your commands like that in logrotate. Either put them in a script and invoke that script in logrotate or put sh -c "..." around your commands with appropriate escaping of existing double quotes.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need help ASAP - FIND - TAR - GZIP

Hi, I need to combined in 1 line the execution below : find * -type f -mtime -$nb_days -print | xargs tar -cvf $MAITUT/BCK_DATA.tar gzip $MAITUT/BCK_DATA.tar.gz The fact that the TAR is very big, at the end I need to generate only the GZ file. The option z on the tar... (2 Replies)
Discussion started by: royinfo.alain
2 Replies

2. 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

3. 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

4. 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

5. Shell Programming and Scripting

Find *.tar files under all subdirectories

Hi there, I'm new to shell scripting... I've a situation like to find *.tar files under all subdirectories in "/home/abcd" and i used the below, find /opt/lhapp ! -name "temp" | more the above works fine.. Now don't need search few direcotries like "/home/abcd/aaaa",... (15 Replies)
Discussion started by: skcvasanth
15 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. 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

8. 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

9. 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

10. UNIX for Dummies Questions & Answers

find a data from several .tar,.gz files

Hi I have a several files with .tar or .gz in a known location. i have files with one of the several files of .tar or .gz text.txt move.txt how do i write a script to find out those particular files .tar or .gz where that contains the above mentioned files (i.e,... (2 Replies)
Discussion started by: gkrishnag
2 Replies

Featured Tech Videos