msabhi@ giving error
# stat -c "%W" wpar_monitor_2days.log
ksh: stat: not found
Quote:
Originally Posted by msabhi
I shall only guide you on one way of achieving the same..you can use this logic if you find it better than ones given by others here...
1>You can get the epoch seconds of the time of creation of the file using stat command
2>Compare this with the epoch seconds of two days behind..if less than the epoch seconds of 2 days behind...go ahead and delete...
To calculate two days behind epoch seconds
Hi Folks,
I have a log file that keeps the information pn the date and time a specific transaction is firedup. I found that the log file keeps growing and I intend to limit the entry to the log file to 30 days.
Log file name is transaction.log, here is the content:
120802_23:47:37 ... (3 Replies)
I want to add these no. these are in the format of
days:hours:minutes:sec
I want result in this format only
0:00:04:59
0:00:00:12
0:00:00:28
0:00:00:03
0:01:29:35
0:00:00:19
0:01:05:21
Is any body ca help me?????
To get This..
Thanks
Nishant (1 Reply)
Many of my servers' /etc/group file have many userid's that does not exist in /etc/passwd file and they need to be deleted.
This happened due to manual manipulation of /etc/passwd files.
I need to do this for 40 servers.
Can anyone help me in achieving this? Even reducing a step or two will be... (6 Replies)
I'm still new to bash script , I have a log file and I want to extract the items within the last 5 days . and also within the last 10 hours
the log file is like this : it has 14000 items started from march 2002 to january 2003
awk '{print $4}' < *.log |uniq -c|sort -g|tail -10
but... (14 Replies)
To delete log files content older than 30 days and append the lastest date log file date in the respective logs
I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs
This is my script
cd... (2 Replies)
Hi All,
Problem Statement:Find all log files under all file systems older than 2 days and zip them. Find all zip files older than 3days and remove them. Also this has to be set under cron.
I have a concerns here
find . -mtime +2 -iname "*.log" -exec gzip {}
Not sure if this will work as... (4 Replies)
I need to collect last 2 days data from /var/log/messages into a separate file (file format: flmessagetimedaymonth). I have collect today's month, date, time information in separate variable. Please help me in this issue (Probably need awk and grep function).
month=$(date|awk '{print $2}')... (4 Replies)
Hi there,
i do get some text files that i'd lile to clean them up based on following rule: if a line starts with " then remove return (new line, carriage return) before ".
Example, my input text file
line 1
line 2
"line 3
I'd like this to come as
line 1
line 2line3
How can i... (4 Replies)
Hi,
I am trying to compare epoch time in a huge log file (2 million lines) with todays date. I have to create two files one which has lines older than 10 days and another file with less than 10 days. I am using while do but it takes forever to complete the script. It would be helpful if you can... (12 Replies)
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
LEARN ABOUT DEBIAN
datetime::format::epoch
DateTime::Format::Epoch(3pm) User Contributed Perl Documentation DateTime::Format::Epoch(3pm)NAME
DateTime::Format::Epoch - Convert DateTimes to/from epoch seconds
SYNOPSIS
use DateTime::Format::Epoch;
my $dt = DateTime->new( year => 1970, month => 1, day => 1 );
my $formatter = DateTime::Format::Epoch->new(
epoch => $dt,
unit => 'seconds',
type => 'int', # or 'float', 'bigint'
skip_leap_secondss => 1,
start_at => 0,
local_epoch => undef,
);
my $dt2 = $formatter->parse_datetime( 1051488000 );
# 2003-04-28T00:00:00
$formatter->format_datetime($dt2);
# 1051488000
DESCRIPTION
This module can convert a DateTime object (or any object that can be converted to a DateTime object) to the number of seconds since a given
epoch. It can also do the reverse.
METHODS
o new( ... )
Constructor of the formatter/parser object. It can take the following parameters: "epoch", "unit", "type", "skip_leap_seconds",
"start_at", "local_epoch" and "dhms".
The epoch parameter is the only required parameter. It should be a DateTime object (or at least, it has to be convertible to a DateTime
object). This datetime is the starting point of the day count, and is usually numbered 0. If you want to start at a different value,
you can use the start_at parameter.
The unit parameter can be "seconds", "milliseconds, "microseconds" or "nanoseconds". The default is "seconds". If you need any other
unit, you must specify the number of units per second. If you specify a number of units per second below 1, the unit will be longer
than a second. In this way, you can count days: unit => 1/86_400.
The type parameter specifies the type of the return value. It can be "int" (returns integer value), "float" (returns floating point
value), or "bigint" (returns Math::BigInt value). The default is either "int" (if the unit is "seconds"), or "bigint" (if the unit is
nanoseconds).
The default behaviour of this module is to skip leap seconds. This is what (most versions of?) UNIX do. If you want to include leap
seconds, set skip_leap_seconds to false.
Some operating systems use an epoch defined in the local timezone of the computer. If you want to use such an epoch in this module, you
have two options. The first is to submit a DateTime object with the appropriate timezone. The second option is to set the local_epoch
parameter to a true value. In this case, you should submit an epoch with a floating timezone. The exact epoch used in "format_datetime"
will then depend on the timezone of the object you pass to "format_datetime".
Most often, the time since an epoch is given in seconds. In some circumstances however it is expressed as a number of days, hours,
minutes and seconds. This is done by NASA, for the so called Mission Elapsed Time. For example, 2/03:45:18 MET means it has been 2
days, 3 hours, 45 minutes, and 18 seconds since liftoff. If you set the dhms parameter to true, format_datetime returns a four element
list, containing the number of days, hours, minutes and seconds, and parse_datetime accepts the same four element list.
o format_datetime($datetime)
Given a DateTime object, this method returns the number of seconds since the epoch.
o parse_datetime($secs)
Given a number of seconds, this method returns the corresponding DateTime object.
BUGS
I think there's a problem when you define a count that does not skip leap seconds, and uses the local timezone. Don't do that.
SUPPORT
Support for this module is provided via the datetime@perl.org email list. See http://lists.perl.org/ for more details.
AUTHOR
Eugene van der Pijll <pijll@gmx.net>
COPYRIGHT
Copyright (c) 2003-2006 Eugene van der Pijll. All rights reserved. This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
SEE ALSO
DateTime
datetime@perl.org mailing list
perl v5.10.1 2007-12-03 DateTime::Format::Epoch(3pm)