Time Modified Issue Please Assist


 
Thread Tools Search this Thread
Operating Systems HP-UX Time Modified Issue Please Assist
# 1  
Old 03-11-2008
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!
# 2  
Old 03-13-2008
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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

IF loop to check the time modified

Hi Frnds, i have a folder test in which files generated daily how to chek the files that are modified on that day as a condition for ex, if then echo "i have got something to do with the file" else echo" sorry" fi i will have more than 3 to 4 files that are modified today. and if... (5 Replies)
Discussion started by: mahesh300182
5 Replies

2. Shell Programming and Scripting

how to change modified time of a file

A files last modified time is like 03/02/2012 xx:xx:xx So what would be the command to convert the last modified in the given signature Thanks for giving time and replying..:) (2 Replies)
Discussion started by: ezee
2 Replies

3. Homework & Coursework Questions

Grep for modified time

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: is it possible to come up with a list of files that are modified before a certain number of hours only using the... (3 Replies)
Discussion started by: momo.reina
3 Replies

4. Shell Programming and Scripting

Grep for modified time

is it possible to come up with a list of files that are modified before a certain number of hours only using the grep command? ex. list files that were modified less than 10 hours ago i've only managed to list files that were created on the same day, i can't seem to figure out how to work... (3 Replies)
Discussion started by: momo.reina
3 Replies

5. Shell Programming and Scripting

Compare Last Modified Time across Time Zone

Hi, I'm new to shell script programming, I only have Java programming background. I'm writing a shell script to do file synchronization between 2 machines that located at different time zone area. Both machine were set its time zone according to its geographical location (Eg: server is at... (1 Reply)
Discussion started by: python
1 Replies

6. Shell Programming and Scripting

changing modified time

How to change the modified time of a file to any specified time. ls -ltr drwxr-xr-x 2 pipe pipe 4096 Jun 10 10:33 coredump_06062008 ---------------------------------------------------------------------- here file coredump_06062008 last modified time is Jun 10 10:33 and i... (1 Reply)
Discussion started by: ali560045
1 Replies

7. UNIX for Dummies Questions & Answers

jus a minor issue. please assist if possible.

for an assignment i'm working on i have 2 minor issues with my code for the lines to be displayed after entering a line of code i.e:- $ ls- l foo1.c foo1.c not found $ recycle -rw-r--r-- 1 usr user 31 foo1.c -rw-r--r-- 1 usr user 31 foo2.c this is my working code . ... (1 Reply)
Discussion started by: jerryboy78
1 Replies

8. Shell Programming and Scripting

Finding out the last modified time for files

I need to find out the last modified time for the files which are older than 6 months. If I use ls -l, the files which are older than 6 months, I am just getting the day, month and year instead of exact time. I am using Korn shell, and SUN OS. Thanks in Advance, Kiran (3 Replies)
Discussion started by: kumariak
3 Replies

9. Shell Programming and Scripting

getting last accessed and modified time together

actually, i'm making an Intrusion Detection System for education purpose (for project) using Bourne shell. The problem I get in that is:- 1. My application should check if there's some modification or alteration in the directory. 2, For that thing, I need to have every attribute of file and... (1 Reply)
Discussion started by: raku05
1 Replies

10. UNIX for Advanced & Expert Users

Modified time

How do you change the modified time of a file on UNIX?? (4 Replies)
Discussion started by: frank
4 Replies
Login or Register to Ask a Question