The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > HP-UX
Google UNIX.COM


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-11-2008
Registered User
 

Join Date: Mar 2008
Posts: 1
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!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-13-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,464
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
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0