Command to clear logs for every 6 hours in solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command to clear logs for every 6 hours in solaris
# 1  
Old 03-16-2011
Command to clear logs for every 6 hours in solaris

Hi Folks,

I need to remove log files for six hours on Solaris. before i used to do for every 24 hours below is the code for 1 day older log files, now i tried using -mmin +360 but it says command not found.
Can someone please help me out!!!

part of the code:
Code:
LOG_FILE=`find /home/Logdir -name "*.log" -mtime +1 -exec ls -lrt {} \; | awk '{print $9}'`
for FILE in LOG_FILE
do
  rm ${FILE}
done

Thanks & Regards
Sendhil.

Last edited by Franklin52; 03-17-2011 at 06:47 AM.. Reason: Please use code tags
# 2  
Old 03-17-2011
with GNU date:

Code:
touch -t `gdate -d "-6 hours" "+%Y%m%d%M%S"`  dummy
find /home/Logdir -type f -name "*.log" ! -newer dummy -ls

if you'd like to remove directly, no need for loop.

Code:
find /home/Logdir -type f -name "*.log" ! -newer dummy -exec rm {} \;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

clear command issue

I need to clear the screen after each iteration but i cannot place clear where it needs to go to do that. I just keep clearing the screen before i can even see the choice I make. HWfile=~/home/daftdave/HW2 loop=y while do tput cup 2 15 ; echo "File Menu List" ... (1 Reply)
Discussion started by: noob
1 Replies

2. Shell Programming and Scripting

Retrieve logs for previous 4 hours

Hi, I am in the process of configuring a script, and i intend it to retrieve logs for previous four hours, and then scan for predefined errors. I am kind of stuck on the log retrieval part where the script will run early morning like 1 AM or 2 AM, the command as posted below will give me... (4 Replies)
Discussion started by: john_prince
4 Replies

3. Shell Programming and Scripting

Retrieve logs for last 4 hours

Our log file looks like this: 2010-11-18 00:57:01,698 ERROR Shipment Error Log:Error Details - Account Id:3962, PO:2710015, Line:2, File:221112901, Version:V1, Desc:Order cannot not be shipped as there are no line items in New state 2010-11-18 14:59:39,960 ERROR... (11 Replies)
Discussion started by: Deepthz
11 Replies

4. Shell Programming and Scripting

How to clear history logs of all terminal sessions

Hi, I would normally clear off the history entries from a terminal by using the following commands: > ~/.bash_history history -c But this will remove the entries of that particular session only. How to prune all the entries of all login sessions for a particular user in a system? N.B:... (3 Replies)
Discussion started by: royalibrahim
3 Replies

5. Solaris

Solaris 10 patching - 14 hours!!!

Hi, we have a problem recently with Sun Fire T200 server, when installing 10_SPARC_EIS-Jul09 patchbundle resulted for 14 hours of outage! Steps, that was done by me is pretty straightforward: reboot -- -s ./installcluster --s10cluster Then I made 1 reboot after kernel patch was installed... (10 Replies)
Discussion started by: masloff
10 Replies

6. Solaris

How to clear STATE - uninitialized in solaris 10

Helloo Frd's, How to clear uninitialized state in solaris 10 Services, the fallowing inetadm shows on my server. I tried svcadm clear, enable... not worked. And also i can't change to enable some of service on that. sara4@root# inetadm ENABLED STATE FMRI disabled ... (6 Replies)
Discussion started by: madhu548
6 Replies

7. Solaris

how to clear command history

hi Any one can help me. I am using Sun_Solaris. The command history set to 100 at .cshrc. I am unable to clear the command histoy. In Linux it is very easy by giving command history -c I could not find any such type command to clear the history. Is there any such type of command for solaris.... (3 Replies)
Discussion started by: prabir
3 Replies

8. UNIX for Dummies Questions & Answers

command not clear

hi, i have an unix command which is as follows: ctmfw /work/CDFC/landing/ZORC.txt CREATE 0 60 1 10 240 I think a txt file called ZORC gets created in the mentioned directory, i am not sure what 0 60 1 10 240 is. Is my understanding correct and also let me know what those numbers denote?... (4 Replies)
Discussion started by: eljcmscrlk
4 Replies

9. UNIX for Dummies Questions & Answers

Delete logs every 3 hours

Hi, I want to setup a cronjob that will delete logs every 2 hours. I have script that delete logs per day. but logging is too big and i want to run a conjob that will delete every 2 hours. this is my current command but it deletes on a per day basis. find . -name "*.log*" -o -name... (3 Replies)
Discussion started by: tungaw2004
3 Replies

10. UNIX Desktop Questions & Answers

Clear logs in unix sco 5.0.4

hi my name es juan i have sco open server 5.0.4 release i need clear the log files as wtmp thanks you very much (1 Reply)
Discussion started by: jtapia
1 Replies
Login or Register to Ask a Question