10-21-2008
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 = sprintf ("%02s",$hour);
$min = sprintf ("%02s",$min);
$sec = sprintf ("%02s",$sec);
print "$year-$mon-$mday $hour:$min:$sec>\n";
Thanks
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
I have seen this posting here:
perl -e '@d=localtime ((stat(shift))); printf "%02d-%02d-%04d %02d:%02d:%02d\n", $d,$d+1,$d+1900,$d,$d,$d' file1.txt
I need to use it inside a perl script. Can anybody please help me out. (5 Replies)
Discussion started by: biswajeet.beher
5 Replies
2. Shell Programming and Scripting
Hi,
I have searched, read and tried, but no luck.
I have this code:
#!/bin/perl -w #-d
use strict;
use POSIX qw(strftime);
my $getprpw_list="/usr/lbin/getprpw -l";
my $host = "nbsol151";
my $user = "genadmin";
my %uid;
my %spwchg;
my %upwchg;
my %slogint; (2 Replies)
Discussion started by: ejdv
2 Replies
3. Shell Programming and Scripting
Hi,
I have command that should run continuously for 30 mins but not every day not once in a week , not one in a month. whenever i call that particular program that command should run for 30 mins and stop.
#Contents of test.pl
`ls -l *.txt`;
#some other lines of code to print
... (1 Reply)
Discussion started by: vanitham
1 Replies
4. Shell Programming and Scripting
How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ?
Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies
5. Programming
Hi All,
I am new to Perl. I have a scenario to code. In a folder I have number of files and they will start with P01 or P02 or P03 and so on..I have to sort them on name first and then on time stamp.
Ex.
File name timestamp
P01_file1.txt 1PM
P02_file1.txt 1AM
P01_file2.txt 2PM... (12 Replies)
Discussion started by: unankix
12 Replies
6. Shell Programming and Scripting
Hi,
I have a file as below
I need to overwrite the 2 nd column alone to numeric format like "06122011030414012345" as per the timestamp value
output file should be
the microseconds can be neglected if required.
Any help will be appreciated.
Thanks in advance (1 Reply)
Discussion started by: irudayaraj
1 Replies
7. Shell Programming and Scripting
Hello
I need to split big xml file into multiple files based on xml declaration. for that i have written one awk 1 liner as below
awk '/<?xml\ version/{i++}{print > "outfile."i}' test123.xml
this is producing the desired out put. but i want the the currenttimestamp with milliseconds in the... (3 Replies)
Discussion started by: dsdev_123
3 Replies
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
I am trying to hit an URL using below command and get the data into an excel sheet.
wget --user=<<USERID>> --pass=<<PASSWROD>> http://www.files.thatbelongstome.com/file1 -O test1.xls
Next step is to consolidate files from 1 to 10 in a single excel sheet and send to my mail. I am working on... (1 Reply)
Discussion started by: PikK45
1 Replies