Sponsored Content
Full Discussion: Log rotation script
Top Forums Shell Programming and Scripting Log rotation script Post 302899020 by e_mikey_2000 on Friday 25th of April 2014 12:17:51 PM
Old 04-25-2014
It seems that you code does not grab all the files for the previous day. here is an example of the log die with the time stamp:
Code:
-rw-r--r--   1 user1     user1     100001759 Apr 23 16:04 log.16
-rw-r--r--   1 user1     user1     100004819 Apr 23 19:21 log.15
-rw-r--r--   1 user1     user1     100000059 Apr 23 22:48 log.14
-rw-r--r--   1 user1     user1     100001107 Apr 24 02:11 log.13
-rw-r--r--   1 user1     user1     100000180 Apr 24 05:35 log.12
-rw-r--r--   1 user1     user1     100002642 Apr 24 11:43 log.11
-rw-r--r--   1 user1     user1     100001593 Apr 24 15:07 log.10
-rw-r--r--   1 user1     user1     100002728 Apr 24 18:09 log.09
-rw-r--r--   1 user1     user1     100003788 Apr 24 21:24 log.08
-rw-r--r--   1 user1     user1     100003583 Apr 25 00:34 log.07
-rw-r--r--   1 user1     user1     100002551 Apr 25 04:19 log.06
-rw-r--r--   1 user1     user1     100004682 Apr 25 06:04 log.05
-rw-r--r--   1 user1     user1     100001351 Apr 25 06:42 log.04
-rw-r--r--   1 user1     user1     100004036 Apr 25 07:05 log.03
-rw-r--r--   1 user1     user1     100001128 Apr 25 10:09 log.02
-rw-r--r--   1 user1     user1     100002646 Apr 25 14:53 log.01
-rw-r--r--   1 user1     user1     37367279 Apr 25 15:59 log

I f I run your code, I only get the follwoing:
Code:
find log* -type f -mtime 1 -exec echo tar -rf $tarfile {} +
tar -rf log.10 log.11 log.12 log.13 log.14 log.15 log.16

The code should return all the files with the time stamp of the previous day which are log.8-log-13.

Does the time aone matter here. My server is in CDT time zone.

Your help is very much appreciated

---------- Post updated at 11:17 AM ---------- Previous update was at 11:16 AM ----------

The application I use already rotate the logs files once they are reached 100 mb. I need to archive and tar up those logs files on a daily bases. The logadm is not useful in this case.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Log Rotation Tool/Script

Hello all Does anyone has an intersting script or a good freeware tool for log rotation that is good for Unix and Linux as well ? My thanks in advance (4 Replies)
Discussion started by: yelalouf
4 Replies

2. HP-UX

Log rotation on HP-UX

Can anyone post a sample log rotate and archive configuration on HP-UX? I really don't know how to do that... :( (3 Replies)
Discussion started by: untamed
3 Replies

3. Shell Programming and Scripting

log rotation

Hello all. Due to some reason I can not use HUP to rotate needed log files. So I use the standard method: cp $file $file.1 cat /dev/null > $file But if Java application in this time writing the output to $file, in the beginning of it appears many "^@^@^@^@^@^@". How to avoid it? Or how... (6 Replies)
Discussion started by: mirusnet
6 Replies

4. Shell Programming and Scripting

Log rotation script

I have the below script to help with disk space cleanup that finds logs older than a specified number of days (say 10 days). I need it to grab "active" logs as well. Problem is an "active log" will not get archived unless I put in 0 days which I don't want to do, I need to leave the past 10 days,... (2 Replies)
Discussion started by: theninja
2 Replies

5. Shell Programming and Scripting

Log rotation issue with script

I have application which to the heavy stdout and I have diverted the stdout to log file. this log file is writing very heavily and we have a script which rotates the logs. logic for rotation is smthing like cp logfile logfile.1 cat /dev/null > logfile this logic was working fine till we... (3 Replies)
Discussion started by: navinmistry
3 Replies

6. Solaris

Solaris log rotation

HI, What is log rotation in Solaris ? What are the essential steps to perform log rotation in Solaris? (1 Reply)
Discussion started by: Revathi@1
1 Replies

7. Solaris

Log rotation, twice

hi folk, need advise regarding the log rotation, i have the logadm set at 30 2 * * * /usr/sbin/logadm so it supposed to rotate once per day, but now it rotated twice! but someone my log will rotate at 2:30 AM, but then another 2 hours later, it creates a new and rotate a new log again,... (2 Replies)
Discussion started by: dehetoxic
2 Replies

8. UNIX for Dummies Questions & Answers

Log Rotation

Hi Guys, Good morning, I just want to know and collect ideas on this one. Regarding rotation of logs as I've observed it's not consistently functioning. I have a server with 8 Partitions, each partition has a dedicated directory for the logs that is needed and I set it every 5mins (300secs) the... (1 Reply)
Discussion started by: rymnd_12345
1 Replies

9. Solaris

Log rotation

Hi All! I seem to have a problem with log rotation, unless I am doing something wrong, I have type the following command for testing purposes to see if the -s option works but he did not: logadm -w /var/adm/messages -C 8 -c -s 512k -t '/var/adm/messages.$n' -z 1 the file is now at this... (7 Replies)
Discussion started by: fretagi
7 Replies

10. OS X (Apple)

Mavericks log rotation

In Mavericks, Apple has apparently moved control of log rotation to ASL. There's a 'ttl' value to determine how long log files will stick around for. I can compress them, change the way they're named, limit them by size, etc. But the one thing I cannot find is how to NOT keep one log file per... (0 Replies)
Discussion started by: jnojr
0 Replies
All times are GMT -4. The time now is 07:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy