How to get past 30 mins time in Solaris?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get past 30 mins time in Solaris?
# 1  
Old 08-05-2013
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:

Code:
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.

Code:
[root@book ~]# date
Tue Apr  2 01:01:49 CST 2013
[root@book ~]# date --date="-30 minutes"
Tue Apr  2 00:32:02 CST 2013
[root@book ~]# date -d '-30 minutes'
Tue Apr  2 00:32:27 CST 2013

thanks!

Moderator's Comments:
Mod Comment Use code tags please, see PM.

Last edited by zaxxon; 08-05-2013 at 12:02 PM.. Reason: code tags
# 2  
Old 08-05-2013
Look at the clock command, it requires TCL 8.5 or of course perl.
# 3  
Old 08-05-2013
# 4  
Old 08-05-2013
Hi blackrageous,

if we use perl, how to write this command? I am not familiar perl Smilie

Thanks!

---------- Post updated at 09:43 PM ---------- Previous update was at 08:40 PM ----------

I find the perl way to implement this requirement.

Code:
#!/usr/bin/perl

$now=localtime(time());
$then=localtime(time()-1800);

print "now is $now\n";
print "then is $then\n";

Thanks for your help!

Last edited by Scott; 08-06-2013 at 01:44 AM.. Reason: Code tags
# 5  
Old 08-06-2013
localtime() has actually two representations, array and scalar.
By assigning it to a $variable the scalar representation is forced.
Certain functions like print can handle both representations, so a cast to scalar is necessary:
Code:
perl -le 'print scalar localtime(time-1800)'

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 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

3. Shell Programming and Scripting

How to select all files added to a directory in the past 5 mins (HP-UX)?

Hey everyone, I need to select all files that were added to a specific directory in the past 5 mins and copy them over to a different directory. I am using HP-UX OS which does not have support for amin, cmin, and mmin. B/c of this, I am creating a temp file and will use the find -newer command... (7 Replies)
Discussion started by: mattkoz
7 Replies

4. UNIX and Linux Applications

From past 10 days my one job is taking lots of time

One of my job is taking long running time. I need to identify from the unix log file can you please help how to troubleshoot. (1 Reply)
Discussion started by: Nsharma3006
1 Replies

5. UNIX for Advanced & Expert Users

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 (6 Replies)
Discussion started by: cka
6 Replies

6. 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

7. Solaris

NTP force system time in the past

Hello I have a question that may sound stupid after and maybe it is. We are syncing our sytem time via ntp from a reference time server. all works quite well but due to a mall applikation which not accepts timestamps from our servers that in the future, and if it even was 1 ms, we have to... (1 Reply)
Discussion started by: demwz
1 Replies

8. Shell Programming and Scripting

Perl - To print past 5 mins timestamp

hi , I would like to ask how to get past 5 minutes system time and date, if i have following to get current time. # get current time ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); $year = $year + 1900; $mon = sprintf ("%02s",$mon+1); $mday = sprintf ("%02s",$mday); $hour =... (1 Reply)
Discussion started by: rauphelhunter
1 Replies

9. Shell Programming and Scripting

Get date and time for past 1 hour from current date

Hi, I need to get the date and time for past 1 hour from the current date. Anyone know how to do so? Thanks (5 Replies)
Discussion started by: spch2o
5 Replies

10. What is on Your Mind?

Past Time

Dear UNIX Folks, I guess everyone of us like to know what sysadmin typically do during his free time. Not what he/she likes as an hobbies.. but what activities does he/she often indulge in other than facing the monitor. Maybe we can come up this a better stereo-typed for sysadmin. I... (8 Replies)
Discussion started by: izy100
8 Replies
Login or Register to Ask a Question