move log files over 12 hours old...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting move log files over 12 hours old...
# 1  
Old 07-05-2004
Question move log files over 12 hours old...

Hi,
I know I can use touch and find's "! -newer" option to list files that are older than a specific time, but what is a good way to get a list of files that are over 12 hours old?
The log pruner will run throughout the day, twice an hour. So I can't easily use a cronjob touch command to generate a file 12 hours old to compare against.
# 2  
Old 07-06-2004
Use perl to subtract 12 hours (43200 seconds) ....
Code:
#!/usr/bin/ksh

STAMP=$(perl -e '($ss, $mm, $hh, $DD, $MM, $YY) = localtime(time() - 43200);
printf "%04d%02d%02d%02d%02d", $YY + 1900, $MM + 1, $DD, $hh, $mm')
touch $STAMP file1
find . -type f ! -newer file1 -print

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Log search and mail it if the log is updated before 24 hours from the current time

Hi , We have around 22 logs , each has different entries. I have to automate this using shell script. The ideas which am sharing is given below 1) We use only TAIL -100 <location and name of the log> Command to check the logs. 2) We want to check whether the log was updated before 24... (13 Replies)
Discussion started by: Kalaihari
13 Replies

2. Shell Programming and Scripting

Move log files with date and delete older than 3 weeks

I have written a script which generate one logfile on every sunday and thursday I want to move the older log files into /tmp directory befor generating new one so i used mv command like mv usr/sbin/appl/logfile.txt usr/sbin/appl/tmp 2) But when i move this file to /tmp it will... (1 Reply)
Discussion started by: Nakul_sh
1 Replies

3. Shell Programming and Scripting

sed 2 hours in log

Hi, I want grep a log between two hours cat server.logsed -n "/24\/01\/2013 09:10/,/24\/01\/2013 10:45/p" server.log24/01/2013 09:10 sssssssssssssss cccccccccccccc nnnnnnnnnnnnn 24/01/2013 10:10 uuuuuuuuuuuuuuu jjjjjjjjjjjjjj llllllllllllll mmmmmmmmmmmmm 24/01/2013 10:30... (22 Replies)
Discussion started by: amazigh42
22 Replies

4. Solaris

how to move old log files

Hi, Need to move all the log files till yesterday without touching today's files in a single command. Source: /sys/logs Dest : /backup It's quite urget. Please help me out folks. (5 Replies)
Discussion started by: Vinothcraig
5 Replies

5. Shell Programming and Scripting

files older than few hours

Hi All I need to know the command which can be used to list the files which are 3 hours old so that it can be deleted. (3 Replies)
Discussion started by: mskalyani9
3 Replies

6. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

7. Shell Programming and Scripting

How to find files by hours old?

I need to be able to do the following: Find files in multiple directories that are 6 hours older than the current time? I am using KSH I tried mmtime but it was not a valid option Any help would be great. Thank you! (2 Replies)
Discussion started by: llsmr777
2 Replies

8. Shell Programming and Scripting

Last 24 hours of a log file

I'm looking to pull the last 24 hours of a log file. Here's what I've got so far: yesterday=$(TZ=$TZ+24 date +"%b %e %H:%M") today=$(date +"%b %e %H:%M") echo $yesterday $today grep -E "^$yesterday|^$today" /var/adm/syslog/syslog.log But that pulls everything from $yesterday from... (1 Reply)
Discussion started by: Bert
1 Replies

9. Shell Programming and Scripting

Files created in last 24 hours

I need a script which list the files which is starting with the word heap*** and that is created before past 24 hours.I need the script using find command. please help me on this. (1 Reply)
Discussion started by: jayaramanit
1 Replies

10. UNIX for Dummies Questions & Answers

delete files that are over 2 hours old

guys, I have a need for a script that will delete all files in a given directory that are over 2 hours old. I will set this up to run in cron. I'm having a little trouble coming up with the syntax that will identify these files. Is there a variation of the ls command that I can use to identify... (3 Replies)
Discussion started by: hedrict
3 Replies
Login or Register to Ask a Question