Cleanup a log file data every 2 days


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cleanup a log file data every 2 days
# 8  
Old 10-26-2012
Suggestion: I think the best approach here is to re-write your script so that it will create a new log file every day and append to it (use date +"%Y%m%d" to name your file). This way you can use find command to find & delete logs that are more than 2 days old.

Last edited by Yoda; 10-26-2012 at 01:55 PM..
# 9  
Old 10-26-2012
Can you try this
Code:
/usr/bin/stat -c "%W" wpar_monitor_2days.log

If this doesn't work, i guess stat is not available on your system...you can check the availability using
Code:
which stat

Quote:
Originally Posted by aix_admin_007
msabhi@ giving error
# stat -c "%W" wpar_monitor_2days.log
ksh: stat: not found
# 10  
Old 10-26-2012
Solution

created log file with extension wpar_monitor_mail_txt.$$, And that way find and remove works...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find a file that's modified more than 2 days ago but less than 5 days ago?

How to find a file that's modified more than 2 days ago but was modified less than 5 days ago by use of any Linux utility ? (4 Replies)
Discussion started by: abdulbadii
4 Replies

2. Shell Programming and Scripting

Filtering log file with lines older than 10 days.

Hi, I am trying to compare epoch time in a huge log file (2 million lines) with todays date. I have to create two files one which has lines older than 10 days and another file with less than 10 days. I am using while do but it takes forever to complete the script. It would be helpful if you can... (12 Replies)
Discussion started by: shunya
12 Replies

3. OS X (Apple)

Text file cleanup

Hi there, i do get some text files that i'd lile to clean them up based on following rule: if a line starts with " then remove return (new line, carriage return) before ". Example, my input text file line 1 line 2 "line 3 I'd like this to come as line 1 line 2line3 How can i... (4 Replies)
Discussion started by: gigagigosu
4 Replies

4. Shell Programming and Scripting

Collect last 2 days data from /var/log/messages

I need to collect last 2 days data from /var/log/messages into a separate file (file format: flmessagetimedaymonth). I have collect today's month, date, time information in separate variable. Please help me in this issue (Probably need awk and grep function). month=$(date|awk '{print $2}')... (4 Replies)
Discussion started by: makauser
4 Replies

5. UNIX for Dummies Questions & Answers

Find all log files under all file systems older than 2 days and zip them

Hi All, Problem Statement:Find all log files under all file systems older than 2 days and zip them. Find all zip files older than 3days and remove them. Also this has to be set under cron. I have a concerns here find . -mtime +2 -iname "*.log" -exec gzip {} Not sure if this will work as... (4 Replies)
Discussion started by: saurabh.mishra
4 Replies

6. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

7. Shell Programming and Scripting

extract information from a log file (last days)

I'm still new to bash script , I have a log file and I want to extract the items within the last 5 days . and also within the last 10 hours the log file is like this : it has 14000 items started from march 2002 to january 2003 awk '{print $4}' < *.log |uniq -c|sort -g|tail -10 but... (14 Replies)
Discussion started by: matarsak
14 Replies

8. Shell Programming and Scripting

awk/sed/ksh script to cleanup /etc/group file

Many of my servers' /etc/group file have many userid's that does not exist in /etc/passwd file and they need to be deleted. This happened due to manual manipulation of /etc/passwd files. I need to do this for 40 servers. Can anyone help me in achieving this? Even reducing a step or two will be... (6 Replies)
Discussion started by: pdtak
6 Replies

9. Shell Programming and Scripting

Add data in days:hours:min:sec format

I want to add these no. these are in the format of days:hours:minutes:sec I want result in this format only 0:00:04:59 0:00:00:12 0:00:00:28 0:00:00:03 0:01:29:35 0:00:00:19 0:01:05:21 Is any body ca help me????? To get This.. Thanks Nishant (1 Reply)
Discussion started by: krishna_sicsr
1 Replies

10. Shell Programming and Scripting

Maintain 30 days data

Hi Folks, I have a log file that keeps the information pn the date and time a specific transaction is firedup. I found that the log file keeps growing and I intend to limit the entry to the log file to 30 days. Log file name is transaction.log, here is the content: 120802_23:47:37 ... (3 Replies)
Discussion started by: odogbolu98
3 Replies
Login or Register to Ask a Question