Sponsored Content
Top Forums Shell Programming and Scripting Check how many minutes ago the last file created Post 302896820 by blakeoft on Wednesday 9th of April 2014 11:14:58 AM
Old 04-09-2014
I think I have a fix for my code above. Try this:
Code:
FOLDER="/nas/testfolder"
FILE=$(ls -alt ${FOLDER} | awk '$NF ~ /^Test/ {print $NF}' | head -1)
FILE_TIME=$(date --reference=$FOLDER/$FILE +%s)
NOW_TIME=$(date +%s) ; echo $((($NOW_TIME-$FILE_TIME)/60))

FOLDER is the folder that you want to look in.

FILE is the most recent file matching your pattern: Long list all files in FOLDER and sort by time. Pipe to awk. Print the last field with files that match the pattern "^Test". Pipe to head. Print the first entry.

FILE_TIME is the number of seconds past a universal date that I don't recall.

NOW_TIME is the number of seconds past that date until now.

Then print the difference of the two times divided by 60.

Note that my code might not work properly if no file matches the pattern.
This User Gave Thanks to blakeoft For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

file was created before 15 days ago.

How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago? It has to be korn shell script. Thanks. (1 Reply)
Discussion started by: YoungBlood
1 Replies

2. Shell Programming and Scripting

How can i search a file which has been created or modified in last five minutes

Hi Can some one please help me How can i search a file which has been created or modified in last five minutes I have used the command find . -mmin -5 and it does not work i get an error -mmin is bad option Please help Much regards Tarun (2 Replies)
Discussion started by: tarundeepdhawan
2 Replies

3. Shell Programming and Scripting

Find unix file created how many days ago?

i want to find unix file created how many days ago? (4 Replies)
Discussion started by: utoptas
4 Replies

4. Shell Programming and Scripting

python test datetime 30 minutes ago

Hello, RHEL5.5 PYTHON=2.4.3 I have 2 python variables using the datetime module. Here is how I call them: print "Current Time: %s" % now print "LastDownloadTime: %s" % LastDownloadTime Here is an example of an issue. Current Time: 2012-01-05 14:06:09.749240... (2 Replies)
Discussion started by: jaysunn
2 Replies

5. Shell Programming and Scripting

How to send a file in UNIX through email which is created only 15 minutes before the current time?

I wanted to send an email to the client whenever there is failed record created in a /feed/HR-76/failed folder after processing of feed file. I can find out with the help of below script that what is the new file created but that file didn't make just 15 minutes before. ... (1 Reply)
Discussion started by: puneetkhullar
1 Replies

6. 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

7. 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

8. UNIX for Beginners Questions & Answers

rsync a file as it gets created and after 3 minutes old

- run a backup job - The jobs creates partial files one after the other, about 2 minutes interval. What i want to do is that while the job is still running or while a file was last modified or created 3 minutes ago, the file should be rsync to a remote server untill the last file has been... (4 Replies)
Discussion started by: malaika
4 Replies
MBOXGREP(1)						      General Commands Manual						       MBOXGREP(1)

NAME
mboxgrep - displays email messages matching a pattern SYNOPSIS
mboxgrep [OPTIONS] PATTERN [MAILBOX] DESCRIPTION
This manual page refers to mboxgrep version 0.7.9. mboxgrep scans a MAILBOX and displays messages matching PATTERN. If a mailbox name is ommited, or a single dash (-) is given instead, it reads from standard input. It can read mbox folders or output from another mboxgrep process from standard input. mboxgrep understands POSIX regular expressions, as well as Perl compatible regular expressions (if enabled at compile time). MAILBOX can be either a: o mbox folder (either plain or compressed) o MH folder o Gnus nnmh or nnml folder o qmail-style maildir folder OPTIONS
-h, --help Display a help screen and exit. -V, --version Display version and copyright information and exit. -r, --recursive Descend into directories recursively. -E, --extended-regexp PATTERN is an extended regular expression. This is default. -G, --basic-regexp PATTERN is a basic regular expression. -P, --perl-regexp PATTERN is a Perl regular expression. Works only if enabled at compile time. -e, --regexp=PATTERN Use PATTERN as a regular expression. -i, --ignore-case Ignore case distinctions. -v, --invert-match Select messages which don't match PATTERN. -H, --headers Match PATTERN against message headers. -B, --body Match PATTERN against message body. -l, --file-lock=METHOD Select file locking METHOD. METHOD is `fcntl', `flock', or `none'. -nl, --no-file-lock Do not lock files. This option is meaningful only if a mbox folder (see below) is scanned. -c, --count Suppress normal output and print a count of matching messages. -o, --output=FOLDER Suppress normal output and write messages to destination folder FOLDER instead. -p, --pipe=COMMAND Pipe each found message to COMMAND -d, --delete Suppress normal output and delete selected messages instead. Use with caution. -nd, --no-duplicates Ignore duplicate messages. -m, --mailbox-format=TYPE Select input and output mailbox TYPE. TYPE can be either `mbox' (default), `zmbox' (meaning `gzip compressed mbox'), `bz2mbox' (meaning `bzip2 compressed mbox'), `mh', `nnml', `nnmh' or `maildir'. EXAMPLES
o Search $MAIL for messages from Dirty Harry: mboxgrep '^From:.*callahan@homicide.SFPD.gov' $MAIL o Display all messages contained in folder ~/Mail/incoming, except those that appear to originate from AOL: mboxgrep -v 'Received:.*aol.com' ~/Mail/incoming BUGS
Report them to address below. NOTICE
Mboxgrep was alomost completely rewritten since version 0.5.3. Additionally, there was no stable 0.6.x branch between 0.5.3 and 0.7.0. SEE ALSO
grep(1), regex(7), perlre(1), mbox(5), RFC 2822 DEDICATION
Mboxgrep is dedicated in loving memory of Vicky, my cat who died of tumor on Sep 12, 2002. You haven't been long with us, but you gave us a lot of joy and all your big heart that stopped ticking too early. I will never forget you. Sleep well, little friend. URL
http://www.mboxgrep.org/ AUTHOR
Daniel Spiljar <dspiljar@world.std.com> 24 Aug 2003 MBOXGREP(1)
All times are GMT -4. The time now is 02:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy