![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting modified time & filename only | senthil_seera | Shell Programming and Scripting | 4 | 04-13-2008 09:50 AM |
| jus a minor issue. please assist if possible. | jerryboy78 | UNIX for Dummies Questions & Answers | 1 | 03-17-2008 12:07 PM |
| getting last accessed and modified time together | raku05 | Shell Programming and Scripting | 1 | 09-22-2005 06:15 AM |
| Checking modified time of files | am97395331 | UNIX for Dummies Questions & Answers | 4 | 07-02-2003 07:55 AM |
| Modified time | frank | UNIX for Advanced & Expert Users | 4 | 06-18-2002 07:57 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Time Modified Issue Please Assist
I am trying to periodically check that the environment variables have not been changed on a HP-UX server. This was going to be easy except I ran into the odd circumstance of having two files that should be created equally be created differently when one is created by command line and the other is created in the korn script. This occurs when i create one text file by doing env > env.txt on the command line and the other one env > envDiff.txt in the korn script. They end up different somehow. Anyway I am now trying to figure out a way where I can periodically refresh the env.txt within the script. If I didn't then issues would arise whenever environment variables are changed on purpose. I decided to try to do this based on time modified but HP-UX doesn't have stat. HP-UX also doesn't have -mmin from what I have read. I also looked into using find but I couldnt get anything to work. Does find always return true even when it doesn't find anything? I would appreciate any ideas/solutions. Below is a breakdown of what I need to accomplish in a korn script:
if(file has not been modified in this long) { env > env.txt } Thanks for your time! |
| Forum Sponsor | ||
|
|
|
|||
|
Code:
#!/bin/ksh
# filetimes compared with now
filetimediff()
{
perl -e '
use POSIX qw(strftime);
$mtime = (stat $ARGV[0])[9];
$seconds1 = strftime "%s\n", localtime($mtime);
$seconds = time;
$seconds -= $seconds1;
print "$seconds: "; # total seconds comment out if not needed
' $1
}
#usage example
dt=$(filetimediff "$1")
if [[ $dt -gt 3600 ]] ; then # 3600 seconds in 1 hour - change to suit
env > env.txt
fi
|
|||
| Google UNIX.COM |