This is a discussion on How to calculate date minus 72 hours? within the Shell scripting forums, part of the Development/Scripting category; There are some log files on my server (CentOS), filenames are like this: 20070929210001.srv0912.tgz I need to find logfiles between ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
There are some log files on my server (CentOS), filenames are like this: 20070929210001.srv0912.tgz
I need to find logfiles between -72 and -2 hours from current date (time). Is it possible to do it with some UNIX commands and implement in shell script then? ![]() Last edited by svinopas; 10-09-2007 at 09:57 PM.. Reason: added OS |
| Sponsored Links | ||
|
|
|
|||
|
I have found how to do this:
Code:
DATE_NOW_UNIXTIME=`date --date=now +"%s"` LOG_HOURS=75 unixtime_LOG_HOURS=`expr $LOG_HOURS \* 60 \* 60` echo `expr $DATE_NOW_UNIXTIME - $unixtime_LOG_HOURS` |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell date command for manipulation and formatting date | newbie4 | Shell scripting | 4 | 10-28-2008 08:33 PM |
| script to ping + date | dendi_rm | Shell scripting | 3 | 09-11-2007 11:42 AM |
| How can I rename a file by its date? | warren | Linux software | 5 | 03-30-2006 01:11 PM |