Find the age of a file in Minutes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find the age of a file in Minutes
# 1  
Old 03-18-2008
Find the age of a file in Minutes

KSH:
Please lt me know how to find the age of a file in minutes(Based on last modified time).
ie, if the file was modified 15 Minutes ago, the output should be 15

Last edited by hari_anj; 03-18-2008 at 05:36 AM.. Reason: for specifying the shell name
# 2  
Old 03-18-2008
Here is how I would do in ksh:
perl -e 'printf "%d\n" ,(time()-((stat(shift))[9]))/60;' file1.txt

Sorry, but sometimes ksh falls short and you need perl for an assist.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find if create time of last created file in a directory is older than 5 minutes

A process xyz is running and creating file1, file2, file3, .... filen. how do i know if the process has stopped and createtime of the last file (filen) is older than 5 minutes? OS is AIX (3 Replies)
Discussion started by: malaika
3 Replies

2. Shell Programming and Scripting

Check file creation Time minutes and if file older then 5 minutes execute some stuff

Hello all, Info: System RedHat 7.5 I need to create a script that based on the creation time, if the file is older then 5 minutes then execute some stuff, if not exit. I thought to get the creation time and minutes like this. CreationTime=$(stat -c %y /tmp/test.log | awk -F" " '{ print... (3 Replies)
Discussion started by: charli1
3 Replies

3. Shell Programming and Scripting

Grep a log file for the last 5 minutes of contents every 5 minutes

Hi all, System Ubuntu 16.04.3 LTS i have the following log INFO 2019-02-07 15:13:31,099 module.py:700] default: "POST /join/8550614e-3e94-4fa5-9ab2-135eefa69c1b HTTP/1.0" 500 2042 INFO 2019-02-07 15:13:31,569 module.py:700] default: "POST /join/6cb9c452-dcb1-45f3-bcca-e33f5d450105... (15 Replies)
Discussion started by: charli1
15 Replies

4. UNIX for Beginners Questions & Answers

Find file that are accessed less than 10 minutes in a directory

Hi All,, I need to find the latest files that are accessed less than 10mins in a particular directory & send those files in an attachment. I could use the below simple one. But if the directory was not updated any recently i could mail the old file again, i need to eliminate that.. What shld... (8 Replies)
Discussion started by: Jeevitha
8 Replies

5. Shell Programming and Scripting

Perl Find file age

Hi I can not say that i am new to perl but today i learned something new, i wanted to know age (last time file got modified) of file so i initially thought of using find -mtime command but when i googled it, i found perl solution for the same my $age = -M $ARGV ; print "$ARGV age is... (1 Reply)
Discussion started by: zedex
1 Replies

6. Shell Programming and Scripting

Find age of files...

I am trying to figure out how to look at only the following directory... /lcl/prd/data/dc003p/dump And search it for any files that have a .arc extension and are older then 24 hours. I have never done anything like this and have no idea where to start. I want to make sure it does not... (10 Replies)
Discussion started by: LRoberts
10 Replies

7. Shell Programming and Scripting

Find files which are <n> minutes old

Hi, i want to find certain files which are more than <n> minutes old,i have the command to find the files say <n> days old(as below) but not in terms of minutes. find . -name "14*.000" -type f -mtime +1 Is there any way to find this? Regards, Cherry (3 Replies)
Discussion started by: cherryven75
3 Replies

8. UNIX for Advanced & Expert Users

Find accessed file in past 1 or 2 minutes, and throw mail.

Can Anyone tell me how to write the Script to "find file(s) in a directory that is being accessed in last 5 minutes, and if there is result of that find, then throw the mail ". Means throw the mail to a person regarding whoever and whenever a file is accessed in a directory. ASAP. Thnks. (2 Replies)
Discussion started by: varungupta
2 Replies

9. UNIX for Dummies Questions & Answers

find a process age

I can write a script to use ps and interigate the output, but is there a command that works similar to the find command for files where I can request a list of all the running processes over 1 day old ? thanks! (8 Replies)
Discussion started by: MizzGail
8 Replies

10. UNIX for Dummies Questions & Answers

How to find the File Age and wait for that...

Hi, I want to know my file is 1 hr 30 min old or not, If 1 hr 30 min old I will do some tasks in that file.. other wise I will wait to 1 hr 30 min and then do the tasks.. how to do it in Unix script? any idea? (3 Replies)
Discussion started by: redlotus72
3 Replies
Login or Register to Ask a Question