[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Getting a files last modified time in minutes.

Posted on 2001-07-13
4
Medium Priority
?
225 Views
Last Modified: 2010-04-21
I am on a RedHat 7.1 system in the bash shell.

I am very new to .sh scripts and have gotten stuck finding a way to do the following:

I want to query a file from a shell script and get it's last modified time in minutes, rounded.  I am taking this and comparing it against various charts to say.....(example)

If modifed in under the last 5 minutes, do A
If modified between 5 and 10 minutes, do B
If modified greater than 10 minutes ago, do C

The problem, I can't figure out how to get the last modified date in minutes and throw it into a variable.

All I can figure out is how to do a standard -N $file and simply know if it's beeen modified at all since it was last looked at.  This won't do as I need.

Can anyone help?

Thank you,
Frank
0
Comment
Question by:GrungyApe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6281762
ls -l file | gawk '{print substr($8,index($8,":")+1)}'
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6281763
ls -l file | gawk '{print substr($8,index($8,":")+1)}'
0
 
LVL 3

Accepted Solution

by:
interiot earned 400 total points
ID: 6282008
set minsmodded=`perl -le 'print int((time-(stat shift)[9])/60+.5)' filename.txt`


That sets $minsmodded to be the number of minutes since filename.txt has been modified.


0
 

Author Comment

by:GrungyApe
ID: 6282101
Perfect, exactly as I needed!
Thank you!
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question