getting time mins ago


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users getting time mins ago
# 1  
Old 01-05-2011
getting time mins ago

Hi
I trying to get 5 mins ago time using below command
echo `date +%R -d "1 min ago"`

but this is giving only current time. Please help
# 2  
Old 01-05-2011
If you want 5 minutes ago, don't use "1 min ago". "1 min ago" is only 1 minute ago.


Code:
$ date "+%R"; date  "+%R" -d "1 min ago"
12:54
12:53
$

# 3  
Old 01-05-2011
Thanks for you reply. but I am getting same results for both

% echo `date "+%R"; date "+%R" -d "1 min ago"`
13:27 13:27
# 4  
Old 01-05-2011
Simple .. you answer in your question itself
Code:
$ date "+%R"
21:25
$ date "+%R" -d "5 mins ago"
21:20

Smilie
# 5  
Old 01-05-2011
What Operating System are you running?
A normal unix "date" command does not support the "-d" switch and just ignores it !
Many versions of Linux support this extension to the "date" command.
# 6  
Old 01-05-2011
Still same May be i am missing some thing?
bash-2.05$ date
Wed Jan 5 13:35:30 EST 2011
bash-2.05$ date "+%R" -d "5 mins ago"
13:35
# 7  
Old 01-05-2011
What Operating System are you running?

Does your "man date" describe a "-d" switch ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find directory is getting files in every 10 mins, if not then when last time file received

Dears, I am looking for a script which will work as a watch directory. I ha directory which keep getting files in every 10 mins and some time delay. I want to monitor if the directory getting the files in every 10 mins if not captured the last received file time and calculate the delay. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

2. UNIX for Beginners Questions & Answers

How to find a file that's modified more than 2 days ago but less than 5 days ago?

How to find a file that's modified more than 2 days ago but was modified less than 5 days ago by use of any Linux utility ? (4 Replies)
Discussion started by: abdulbadii
4 Replies

3. UNIX and Linux Applications

Sendmail delay: 3 mins 11 secs... Every time.

Hi all, I would like some help with a sendmail problem: We have a new system comprising of 4 T7-1 servers, each hosting 5 LDOMs, all domains running Solaris 11.3 All emails sent from every one of these domains (including the control domains) sit in the queue for 3 mins 11 secs (sometime 3m 12s,... (11 Replies)
Discussion started by: Mysturji
11 Replies

4. Shell Programming and Scripting

Need logs 5 mins old

I need 5 mins old logs to be dumped into a a new file. The date formats in the two log files are Can you suggect for both formats ? bash-3.2$ uname -a SunOS myserver 5.10 Generic_150400-26 sun4v sparc sun4v ---------- Post updated 05-04-16 at 12:24 AM ---------- Previous update was... (2 Replies)
Discussion started by: mohtashims
2 Replies

5. Shell Programming and Scripting

How to get past 30 mins time in Solaris?

Hi guys, could you help to find a way to get the past 30 mins time in solaris. version: bash-3.00# uname -a SunOS solaris 5.10 Generic_142910-17 i86pc i386 i86pc I had tried the following ways, it works fine in GNU Linux, but doesn't work in Solaris. # date Tue Apr 2 01:01:49 CST... (4 Replies)
Discussion started by: ambious
4 Replies

6. Shell Programming and Scripting

How long ago since time - Using perl

echo "1337124526" | perl -pe 's/(\d+)/easttime($1)/e' the above gives a date and time. how can i subtract the date and time given by this command, from the current present date? can this be a one liner or as close to a one-liner as possible? (1 Reply)
Discussion started by: SkySmart
1 Replies

7. Shell Programming and Scripting

tail for 15 mins

Hi, I want to write a script which will tail a particular file for 15 mins and then sleep for 10 mins and again tail for 15 mins. This cycle will go on for a limited period of time. How can i ensure that tail command will run for 15 mins before calling sleep command Thanks (6 Replies)
Discussion started by: @bhi
6 Replies

8. Shell Programming and Scripting

how to calculate the time 10 mins ago?? unix

Hi guys, Im trying to subtract time in ksh script. i.e. basically im querying a database and i want to get the time 10mins before hand..(from) in ksh CurrMin=$(date "+%M") from=`expr $CurrMin - 10` to=$CurrMin however if i run this i say at 2 or 3 mins past the hour, i.e.... (7 Replies)
Discussion started by: k00061804
7 Replies

9. Shell Programming and Scripting

file old than 10 mins to alert

Hello We have to monitor a FTP utility where we have to monitor for checking presence of a file in directory With max time allowed for a file to stay in the directory on FTP client server as 10 mins. The only way we are going to be able to do what we are lookign for is to write a script to... (1 Reply)
Discussion started by: vivkas
1 Replies

10. Shell Programming and Scripting

Finding files which are modified few mins ago

Hi All, I have a requirement to find out the files which are modified in the last 10 minutes. I tried the find command with -amin and -mmin options, but its not working on my AIX server. Can anyone of you could help me. Thanks in advance for your help. Raju (3 Replies)
Discussion started by: rajus19
3 Replies
Login or Register to Ask a Question