HOWTO - File Timestamps - how old is a file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HOWTO - File Timestamps - how old is a file?
# 1  
Old 03-02-2011
HOWTO - File Timestamps - how old is a file?

Hi all,

Can anyone please advise how to get/display the timestamp of a file and at the same time display how old the file is?

For example, if I have a file that is created on January 01, 2011 at 1000 and today is January 03, 2011 2200, I want a script to be able to display the timestamp creation of the file, i.e. display January 01, 2011 1000 and at the same time report that it is 2 days and 12 hours old.

What am trying to do is to check the timestamp of my backup files. I have a script that create backups of my database so I want to be able to check on a daily basis the creation date of each backup files and if I don't have a backup files in the last 2 days / 24 hours, then I send out an email.

Any advise on how to get about writing a script like this will be very much appreciated. Thanks in advance.
# 2  
Old 03-02-2011
# 3  
Old 03-02-2011
There is no "file creation timestamp" in unix. The nearest is the last modified timestamp of the inode. Beware that some backup software changes this timestamp.
It is good practice to include an apppropriate timestamp in the filename or directory name of a backup.


The "last modified" timestamp is usually good enough. This is the timestamp used by "ls -la".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find file between timestamps Query

On my linux box, I have a file say dump.txt. I then need to move to another seperte folder and need to find only one file with extension *.tar that has the closest timestamp after / next to the timestamp of the dump.txt. (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Search lines between two timestamps in a file

Hi, I want to pull lines between two timestamps from a file. When I just insert values directly it is working fine. sed -n '/2014-02-14 05:30/,/2014-02-14 05:31/p' Logfile When I try to insert variable it is not working. sed -n '/TZ=GMT+1 date +%Y-%m-%d" "%H:%M:%S/,/TZ=GMT date... (2 Replies)
Discussion started by: Neethu
2 Replies

3. Shell Programming and Scripting

To search lines between two timestamps in a file

I have a log file where every line starts with a time stamp. I have to extract lines from the file within a given time stamp. For example: IF the file is like this: 2012-08-19 10:34:03,446|WebContainer : 56|OrderHeaderDaoImpl|findByKeys|26| 2012-08-20 11:34:03,463|WebContainer :... (8 Replies)
Discussion started by: abhinalluri
8 Replies

4. Shell Programming and Scripting

How to fetch data between two timestamps in a file using KSH

Hi, I got a requirement to fetch data between two time stamps in a big log file and grep for a word in that particular time interval of data. Here is my log looks like: 2012/04/08-14:35:56 Abcdefg 2012/04/08-14:35:56 Hijklmnophhoishfw 2012/04/08-14:35:56... (1 Reply)
Discussion started by: siri_886
1 Replies

5. AIX

howto extract a file from a bff file?

Hi howto extract a file from a bff file? Is it possible? thanks Israel. (1 Reply)
Discussion started by: iga3725
1 Replies

6. Shell Programming and Scripting

shell script to search content of file with timestamps in the directory

hello, i want to make a script to search the file contents in my home directory by a given date and output me the line that has the date... (10 Replies)
Discussion started by: psychobeauty
10 Replies

7. Shell Programming and Scripting

File timestamps in different servers.

Hello, I need to gather timestamps and file sizes of all the list of files in different servers. The servers and file locations will be different for each file. I'm thinking of keeping a comman delimited file with {source_server_name,source location, file name} as records in the file. So, I... (1 Reply)
Discussion started by: bperl
1 Replies

8. Shell Programming and Scripting

Howto create a file

Hi folks, How do we create a file using shell script? i mean to say that do we use is it a good approch to do echo "abc" >file echo "xxxx" >>file or is there any better method? Thanks, Amit (5 Replies)
Discussion started by: amit4g
5 Replies

9. UNIX for Advanced & Expert Users

mv command and file-timestamps

Hi all, I need help to find out if it is possible (if so, how? :D ) to move a hard link to a given file without making the main file i-node modification time change. That is: I have a file myFile.txt , and I have a link myLink.dat to that file (obtained by: ln myFile.txt myLink.dat).... (1 Reply)
Discussion started by: gian1975
1 Replies

10. UNIX for Dummies Questions & Answers

find command not giving file names accord. to timestamps

Currently iam working on solaris environment, Iam using find command to get list of all files between any two given dates. But the find command is not listing files accord. to timestamp. I tried using -exec option as -exec ls -ltr {} \; Still the files are not listed according to timestamp..... (8 Replies)
Discussion started by: thanuman
8 Replies
Login or Register to Ask a Question