1830895 Members
1981 Online
110017 Solutions
New Discussion

How to check timestamp

 
network_4
Advisor

How to check timestamp

I would like to check the timestamp of each one of of the files
and process only files which whose creation time is 30 min less then current time. Please let me know if anyone knows how to do.
6 REPLIES 6
Sunny Jaisinghani
Trusted Contributor

Re: How to check timestamp

Hi,

you can view the time stamp by long listing the files.

ls -l will give you the time stamps
ls -lt will give you the sorted order of files with the file accessed latest will be listed first.

to filter the files according to time you can refer man page for find.
the options -atime, -mtime, -ctime may help.

Regards
Oviwan
Honored Contributor

Re: How to check timestamp

Hey

Perhaps you can write a script with this infos:

ls -l filename (modification time)
ls -lc filename (change time)
ls -lu filename (access time)

Regards
Peter Godron
Honored Contributor

Re: How to check timestamp

Hi,
as you will know HPUX does not keep the creation time of a file, only its last access time.
So the closest you can get is to a list of files created within the last 30 minutes is:

create a dummy file and change the time ont he file with touch -t, setting it to your required time (systime - 30 minutes).
Now you can run a find with the -newer option, using the dummy file as a parameter.

For similar threads:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=67845
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=762560

mtime,atime etc only work on multiples of 24 hrs. For a quick solution you could try ls -lrt (list in recverse time order)


Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.
ISE-test user
New Member

Re: How to check timestamp

you can use touch command in order to change
access, modification, change times of a file.
Hein van den Heuvel
Honored Contributor

Re: How to check timestamp

#include no_create_time_warning.txt

Must unix folks would 'touch' a reference file with a timestamp of 30 minutes ago and then find -newer.

I would use the perl -M file operator which gived the modification time in days.

Something like

perl -e 'foreach () { $m=-M; if ($m > 1800/86400) { printf qq(%7.3f %s Processing...\n), $t, $_}}'

Hein.
Peter Godron
Honored Contributor

Re: How to check timestamp

Hi,
you have been given quite a few answers.
Can you now please update the thread.

If the problem is solved, could you please complete the thread by awarding points to helpful answers and summarising the solution for you.

Please read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.

So far you have only awarded points to 1 out of 15 answers !!