HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Testing for 1 hour old.
Operating System - HP-UX
1833431
Members
3214
Online
110052
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2002 10:49 AM
02-28-2002 10:49 AM
I am running a program to restart Java if it gets errors in the log file.
I would like to add a routine to restart java if the log does not get updated for at least one hour.
How do you go about comparing the time stamp of a file modification, to the current time, and see if it is at least 1 hour or more old?
Thanks
I would like to add a routine to restart java if the log does not get updated for at least one hour.
How do you go about comparing the time stamp of a file modification, to the current time, and see if it is at least 1 hour or more old?
Thanks
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2002 11:15 AM
02-28-2002 11:15 AM
Solution
Hi Fred:
You can do this in the shell with a combination of touch to create a file with a timestampo then find -newer (or -older) but a much cleaner way is to use this perl script:
fileage.pl -m -s 3600 myfile
The will silently return a 1 exit status if myfile has been modified within the last hour or 0 otherwise.
fileage.pl -m -s 3600 myfile
STAT=$?
if [ ${STAT} -eq 0 ]
then
echo "File was modified"
else
echo "File not modified"
fi
You can also add a -v argument to actually echo 1 or 0 to stdout. fileage.pl -u will display a full usage.
Regards, Clay
You can do this in the shell with a combination of touch to create a file with a timestampo then find -newer (or -older) but a much cleaner way is to use this perl script:
fileage.pl -m -s 3600 myfile
The will silently return a 1 exit status if myfile has been modified within the last hour or 0 otherwise.
fileage.pl -m -s 3600 myfile
STAT=$?
if [ ${STAT} -eq 0 ]
then
echo "File was modified"
else
echo "File not modified"
fi
You can also add a -v argument to actually echo 1 or 0 to stdout. fileage.pl -u will display a full usage.
Regards, Clay
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2002 11:17 AM
02-28-2002 11:17 AM
Re: Testing for 1 hour old.
Language preference?
In C, perl it's pretty trivial.
Use fstat to get the file status information.
Time in Unix is an integral number counted in seconds. Make sure the difference between now and last modified is > 3600 (60 seconds * 60 minutes). Restart.
In C, perl it's pretty trivial.
Use fstat to get the file status information.
Time in Unix is an integral number counted in seconds. Make sure the difference between now and last modified is > 3600 (60 seconds * 60 minutes). Restart.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2002 11:21 AM
02-28-2002 11:21 AM
Re: Testing for 1 hour old.
Hi again Fred:
Oops my shell logic was wrong. The text description was correct but the example was wrong. It should be:
fileage.pl -m -s 3600 myfile
STAT=$?
if [ ${STAT} -eq 1 ]
then
echo "File was modified"
else
echo "File not modified"
fi
Notice that you have 1 second resolution and you can use -a for last access or -c for last create/chmod.
Oops my shell logic was wrong. The text description was correct but the example was wrong. It should be:
fileage.pl -m -s 3600 myfile
STAT=$?
if [ ${STAT} -eq 1 ]
then
echo "File was modified"
else
echo "File not modified"
fi
Notice that you have 1 second resolution and you can use -a for last access or -c for last create/chmod.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP