![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pls help : file stamp issue on HP UX Servers | siddaonline | UNIX for Dummies Questions & Answers | 2 | 07-04-2007 12:14 PM |
| how do i put a time stamp in a file name | jhamm | Shell Programming and Scripting | 5 | 01-29-2007 10:00 AM |
| greping with time stamp | arunkumar_mca | Shell Programming and Scripting | 1 | 07-28-2006 05:20 AM |
| capturing the time stamp | pavan_test | UNIX for Dummies Questions & Answers | 4 | 07-18-2006 02:35 PM |
| How to MV without changing Time Stamp | redlotus72 | UNIX for Dummies Questions & Answers | 3 | 07-15-2005 07:16 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Perl, time stamp issue. 60th minutes
Hi Guys, Could you tell me how you can get the time stamp for 60th minutes? Currently, we name our file using time stamp upto minutes and then add seconds at the end starting from 01. And when the seconds reaches 60 we simply add 1 to the time stamp and reset the seconds to 00. But the problem occurs when the minute hits 60. For example, file name starts from 20090330225900.csv then goes to 20090330225959.csv. Then instead of going to 20090330230000.csv it goes to 20090330226000.csv. Following is the code, Code:
$seconds_count = 1;
$date_r = `date +%Y%m%d%H%M`;
$date_r = substr($date_r,0,-1);
foreach $blahblah{
if (length($seconds_count) == 1){
$seconds_count = "0" . $seconds_count;
}
# Build up the filename
$filename = " .
$date_r .
$seconds_count .
".csv";
$seconds_count++;
if ($seconds_count > 59){
$date_r = $date_r + 1;
$seconds_count = 0;
}
Do you recon the following would work? Code:
if ($seconds_count > 59){
$date_r = `date +%Y%m%d%H%M`+ 1;
$seconds_count = 0;
}
Last edited by Yogesh Sawant; 03-31-2009 at 03:24 AM.. Reason: added code tags |
|
||||
|
And what should happen if the file name is:
20090331245959.csv That will roll the day and month over as well as the HHMMSS. Is that what you want? Besides being plenty of date modules available, there is the core Time::Local module and POSIX, you don't have to use the shells date command. |
|
||||
|
Quote:
Hi Kevin, Yes it should roll the day and month as well just as normal date does. Could you kindly give an example how I can do this? Cheers |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|