Sponsored Content
Operating Systems HP-UX Time Modified Issue Please Assist Post 302175168 by jim mcnamara on Thursday 13th of March 2008 07:59:40 AM
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

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
TIME(2) 						     Linux Programmer's Manual							   TIME(2)

NAME
time - get time in seconds SYNOPSIS
#include <time.h> time_t time(time_t *t); DESCRIPTION
time returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds. If t is non-NULL, the return value is also stored in the memory pointed to by t. RETURN VALUE
On success, the value of time in seconds since the Epoch is returned. On error, ((time_t)-1) is returned, and errno is set appropriately. ERRORS
EFAULT t points outside your accessible address space. NOTES
POSIX.1 defines seconds since the Epoch as a value to be interpreted as the number of seconds between a specified time and the Epoch, according to a formula for conversion from UTC equivalent to conversion on the naive basis that leap seconds are ignored and all years divisible by 4 are leap years. This value is not the same as the actual number of seconds between the time and the Epoch, because of leap seconds and because clocks are not required to be synchronised to a standard reference. The intention is that the interpretation of sec- onds since the Epoch values be consistent; see POSIX.1 Annex B 2.2.2 for further rationale. CONFORMING TO
SVr4, SVID, POSIX, X/OPEN, BSD 4.3 Under BSD 4.3, this call is obsoleted by gettimeofday(2). POSIX does not specify any error conditions. SEE ALSO
ctime(3), date(1), ftime(3), gettimeofday(2) Linux 2.0.30 1997-09-09 TIME(2)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy