Register
It is currently Sat Nov 01, 2014 12:04 am

Bash script for check if a file is more 2 hours old


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sun Nov 22, 2009 10:34 am   

Joined: Wed Dec 03, 2008 5:19 am
Posts: 5
Hello.

I would like know how to do for know if a directory is more than 2 hours old or not, is for backups purposes.

If [ directoryismore than 2 hours old]

echo "old"
else

echo "pass"

fi


Thanks


Top
 Profile  
 PostPosted: Sun Nov 22, 2009 11:35 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 552
Hi kokolisso,

you could play with `stat -c%Z` and `date +%s` to have the time elapsed since last change of the directory.
If the result of the two EPOCHs substraction is more than 7200, directory is old.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP