Find if file is 45 min old if yes delete


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find if file is 45 min old if yes delete
# 1  
Old 03-18-2014
RedHat Find if file is 45 min old if yes delete

Hello,
we have process2(my_pro.sh) which check for the file Pr_rn_Chk (generated by other process1). The process runs every 15 min.
if exist Pr_rn_Chk the process will exit. Else it will continue.

I want to check if the file Pr_rn_Chk is older than 45 min delete the file. so that 4th run should be ok.

can someone suggest easiest method to do that.
# 2  
Old 03-18-2014
# 3  
Old 03-18-2014
Since you run every 15 minutes, you can have three marker files you rename and touch to give you a 45 minute marker file.
Code:
Every 15 minute Cron script:
 
#!/usr/bin/ksh
 
find head_dir -type f ! -newer marker45 | xargs -n128 rm
 
mv marker30 marker45 # destroys old marker45
 
mv marker15 marker30
 
touch marker15

The xargs gives you economy of scale and pipeline parallelism.

Last edited by DGPickett; 03-18-2014 at 02:44 PM..
# 4  
Old 03-18-2014
Below code will display file if it is older than 45 mins
Code:
find dir_name -type f -name "Pr_rn_Chk" -mmin +45

If you want to delete the file
Code:
find dir_name -type f -name "Pr_rn_Chk" -mmin +45 -exec rm -f {} \;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find min and max time taken from a log file

You have a log file as attached in sample input with various operations and time taken by each of them. Write a script to find the min and max time taken for each operation. Sample output is attached. Sample Input is given as below: operation1,83621 operation2,72321 operation3,13288... (1 Reply)
Discussion started by: Chandan_Bose
1 Replies

2. Shell Programming and Scripting

Script to find min for each unique value

I need a script that will search through multiple files and when the first 2 columns match, print out Columns 1 and 2 and the minimum value. File 1 24.01 -81.01 1.0 24.02 -81.02 1.0 24.03 -81.03 3.0 File 2 24.01 -81.01 5.0 24.02 -81.02 3.0 24.03 -81.03 ... (3 Replies)
Discussion started by: ncwxpanther
3 Replies

3. Shell Programming and Scripting

awk script to find min and max value

I need to find the max/min of columns 1 and 2 of a 2 column file what contains the special character ">". I know that this will find the max value of column 1. awk 'BEGIN {max = 0} {if ($1>max) max=$1} END {print max}' input.file But what if I needed to ignore special characters in the... (3 Replies)
Discussion started by: ncwxpanther
3 Replies

4. Shell Programming and Scripting

to find min and max value for each column!

Hello Experts, I have got a txt files which has multiple columns, I want to get the max, min and diff (max-min) for each column in the same txt file. Example: cat file.txt a 1 4 b 2 5 c 3 6 I want ouput like: cat file.txt a 1 4 b 2 5 c 3 6 Max 3 6 Min 1 4 Diff 2 2 awk 'min=="" ||... (4 Replies)
Discussion started by: dixits
4 Replies

5. Shell Programming and Scripting

How to find the average,min,max ,total count?

Hi , Below is my sample data,I have this 8 column(A,B,C,D,E,F,G,H) in csv file. A , B ,C ,D ,E ,F,G ,H 4141,127337,24,15,20,69,72.0,-3 4141,128864,24,15,20,65,66.0,-1 4141,910053,24,15,4,4,5.0,-1 4141,910383,24,15,22,3,4.0,-1 4141,496969,24,15,14,6,-24.0,-18... (7 Replies)
Discussion started by: vinothsekark
7 Replies

6. Shell Programming and Scripting

Find min.max value if matching columns found using AWK

Input_ File : 2 3 4 5 1 1 0 1 2 1 -1 1 2 1 3 1 3 1 4 1 6 5 6 6 6 6 6 7 6 7 6 8 5 8 6 7 Desired output : 2 3 4 5 -1 1 4 1 6 5 6 8 5 8 6 7 (3 Replies)
Discussion started by: vasanth.vadalur
3 Replies

7. Shell Programming and Scripting

Find a min,group by.

I have a data file with records: A123|Peter|20 A123|Jack |10 B222|Helen|15 B222|Jane |13 B222|Guy |30 I want for find the min for $3 group by $1. i.e A123|Jack|10 B222|Jane|13 Thanks. (4 Replies)
Discussion started by: Shivdatta
4 Replies

8. Shell Programming and Scripting

Delete File 5 Min old in Unix (Bourne Shell)??

Guys, I am writing a script to delete files 5 min old in Sun Os Unix. find . -name "*.txt" -mtime +1 -print I could find an equivalent command to look for files which are 5 min old. i tried -mmin option it didn't work either. Can any body trow a light on this. Cheers :) S:b: (5 Replies)
Discussion started by: sudharma
5 Replies

9. Shell Programming and Scripting

how to delete the files which are the 30 min older...?

Hi all, i have a simple question that i want to find out the 30 minutes older files and delete those files from the particular location(Folder) Generally for this purpose used to retreive the files with "atime" command For example: find and delete the 2 days older log files use this below... (2 Replies)
Discussion started by: psiva_arul
2 Replies

10. Shell Programming and Scripting

how to find min, max dates in a file

hello friends...:-) i need some help i have a file cantain like this Star1 ,NetWork,09/02/2008 Star1 ,NetWork,10/02/2008 Star1 ,NetWork,11/02/2008 Star2 ,NetWork,08/03/2008 Star2 ,NetWork,09/04/2008 Star2 ,NetWork,10/05/2008 i need to find out min, max dates the output look like... (6 Replies)
Discussion started by: gemini106
6 Replies
Login or Register to Ask a Question