Sponsored Content
Top Forums Shell Programming and Scripting how to find the time before 30 minutes Post 302346698 by vikash_k on Monday 24th of August 2009 12:56:21 AM
Old 08-24-2009
Quote:
Originally Posted by panyam
Code:
perl -le 'print scalar localtime (time() - 2*60*60);'

Thanks a lot. This is what i was expecting. As i am new to perl. Could you please tell me hoie can i pass parameterized value to this command. As after some time my requirement is changed for 50 mins instead of 30 mins.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process Time in hours or minutes only

Hi i want to print the time of a process in hours only..(or) in minutes only.Is there anyway to print the process such like that when i give the commnand like following #ps -eo pid,time PID TIME 412 01:49:32 481 00:03 it shows in HH:MM:SS format: Could anyone... (1 Reply)
Discussion started by: srikanthg
1 Replies

2. Shell Programming and Scripting

subtract minutes from time

i have the time 20100421043335 in format (date +%Y%m%d%H%M%S),and i want to be able to get the previous time 2 minutes ago,which is 20100421043135 (9 Replies)
Discussion started by: tomjones
9 Replies

3. Shell Programming and Scripting

Determine previous time in minutes

I have several logs with where the time stamp in the logs are "YYYYMMDDHHMM". I would like to check the last line in each file to make sure the entry is less than 5 minutes old. My timezone is EST5EDT so the following will work for 1 hour. But I need something easy for 5 minutes ago.... (5 Replies)
Discussion started by: oldman2
5 Replies

4. Solaris

How to show time minus 60 minutes?

In Redhat it is easy.... date --date="60 minutes ago" How do you do this in Solaris? I got creative and got the epoch time but had problems.. EPOCHTIME=`truss date 2>&1 | grep "time()" | awk '{print $3 - 900}'` echo $EPOCHTIME TIME=`perl -e 'print scalar(localtime("$EPOCHTIME")),... (5 Replies)
Discussion started by: s ladd
5 Replies

5. Shell Programming and Scripting

grep the time within given minutes

Mar 26 15:25:11 : jdoe : TTY=pts/2 ; PWD=/home/jdoe ; USER=root ; COMMAND=/usr/bin/su - Mar 26 15:28:52 : jdoe : 3 incorrect password attempts ; TTY=pts/2 ; PWD=/home/jdoe ; USER=root ; COMMAND=/usr/bin/su - Mar 25 12:23:07 : jdoe : TTY=pts/2 ; PWD=/home/jdoe ; USER=root ; ... (6 Replies)
Discussion started by: Daniel Gate
6 Replies

6. Shell Programming and Scripting

How to convert 24 Hr Time Format into Minutes?

Hello All I know the general Logic behind it but do not know the shell programming so much. For Example, The Time is stored in a given Variable if the Time is 0800 then i need to extract the last digits of the number and Add it to the Remaining Digit of the Number which is multiplied by... (7 Replies)
Discussion started by: Ajesh
7 Replies

7. Shell Programming and Scripting

Time difference in minutes

Hi Folks, I have a text file that has only time in the format HH:MM:SS like seen below. 21:36:17 23:52:08 I need to find the difference in minutes alone from this text file so the result would be 136. Thanks Jay (11 Replies)
Discussion started by: jayadanabalan
11 Replies

8. Shell Programming and Scripting

How to get a time minus 60 minutes?

Hello, date --date '-60 min ago' +'%Y-%m-%d %H:%M:%S,%3N' Above command gives the date and time minus 60 minutes but the problem i am facing is, i do not want to hardcode the value 60 it is stored in a variable var=60 now if i run below command , i get error date --date '-$var min... (3 Replies)
Discussion started by: Ramneekgupta91
3 Replies

9. Shell Programming and Scripting

Check file creation Time minutes and if file older then 5 minutes execute some stuff

Hello all, Info: System RedHat 7.5 I need to create a script that based on the creation time, if the file is older then 5 minutes then execute some stuff, if not exit. I thought to get the creation time and minutes like this. CreationTime=$(stat -c %y /tmp/test.log | awk -F" " '{ print... (3 Replies)
Discussion started by: charli1
3 Replies

10. UNIX for Beginners Questions & Answers

Find if create time of last created file in a directory is older than 5 minutes

A process xyz is running and creating file1, file2, file3, .... filen. how do i know if the process has stopped and createtime of the last file (filen) is older than 5 minutes? OS is AIX (3 Replies)
Discussion started by: malaika
3 Replies
Epoch(3)						User Contributed Perl Documentation						  Epoch(3)

NAME
Time::Epoch - Convert between Perl epoch and other epochs SYNOPSIS
#!/usr/bin/perl -wl use Time::Epoch; my $perlsec = 966770660; # Sun Aug 20 07:24:21 2000 -0400 on Mac OS my $epochsec = perl2epoch($perlsec, 'macos', '-0400'); my $perlsec2 = epoch2perl($epochsec, 'macos', '-0400'); print $perlsec; print $perlsec2; print $epochsec; # correct time on Unix: print scalar localtime $perlsec; # correct time on Mac OS (-0400): print scalar localtime $epochsec; DESCRIPTION
Exports two functions, "perl2epoch" and "epoch2perl". Currently only goes between Perl (Unix) epoch and Mac OS epoch. This is in preparation for an eventual move of Perl to its own universal epoch, so we can get the system epoch of any platform that differs from Perl's. Epochs o macos Takes additional optional parameter of time zone differential. If time zone differential not supplied, we guess by getting the different between "localtime" and "gmtime" with <Time::Local::timelocal>. BUGS
o Hm. With the above test, "scalar localtime $perlsec" under my Linux box and "scalar localtime $epochsec" under my Mac OS box are off by one second from each other. Maybe a leap second thing? Odd. AUTHOR
Chris Nandor <pudge@pobox.com>, http://pudge.net/ Copyright (c) 2000-2003 Chris Nandor. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, distributed with Perl. SEE ALSO
perl(1), perlport(1), Time::Local. perl v5.18.2 2003-05-21 Epoch(3)
All times are GMT -4. The time now is 11:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy