Hi all,
I am working on a script that scans several directories looking for a particular file in each and see if the file is older than 30 minutes.
The filename is core.txt in all of the directories.
Currently, I have a script that works about 90% of the time, but lately it's been flaky, and after looking at the script (I didn't write it), I figured there must be a better way.
What's a quick and easy way to go about this?
I was thinking of this:
1. Touch a file with a timestamp exactly 30 minutes from the current time (not sure how to do this in KSH).
2. Get the last modified time of the core.txt file, and compare it like this:
if [[ core.txt -ot timestamp.txt ]] ; then
3. Touch a flag file to notify me that the file is older than 30 minutes old.
Notes:
The core.txt file is a file that collects output from a C program. Would I want to check on the last modified time or last accessed time? (If using the find command).
Any help or example would be greatly appreciated! Thanks!
I am working on a script that scans several directories looking for a particular file in each and see if the file is older than 30 minutes.
The filename is core.txt in all of the directories.
Currently, I have a script that works about 90% of the time, but lately it's been flaky, and after looking at the script (I didn't write it), I figured there must be a better way.
What's a quick and easy way to go about this?
I was thinking of this:
1. Touch a file with a timestamp exactly 30 minutes from the current time (not sure how to do this in KSH).
2. Get the last modified time of the core.txt file, and compare it like this:
if [[ core.txt -ot timestamp.txt ]] ; then
3. Touch a flag file to notify me that the file is older than 30 minutes old.
Notes:
The core.txt file is a file that collects output from a C program. Would I want to check on the last modified time or last accessed time? (If using the find command).
Any help or example would be greatly appreciated! Thanks!