I have a log like this:
I need to get the last hour of log and have made a script for it.
It works, but I need some help simplify it.
I do not need NOW, getting to end of file is good enough, but how to do it.
Can I get all in one line (not use $FROM and $NOW)
Maybe speed it up some. Log size is 2270000 lines long and growing. Takes around 3 seconds to complete.
So I tried this
#!/bin/sh
FROM=$(date +%b" "%d" "%H:%M:%S -d "-1 hour")
NOW=$(date +%b" "%d" "%H:%M:%S)
cat /var/log/daemon.log | awk '$0>=from&&$0<=to' from="$FROM" to="$NOW" | wc -l
I want to get CPU average value only (not required user CPU & memory) with each hours on individual date. The sample output is below
| | | User |Memory| User |
Date | Time |CPU %|CPU % | % |Mem % |
03/02/2015|00:00:00| 24.56| 20.66| 89.75| 63.48|... (13 Replies)
Hi, im trying to write a grep script that returns me the last inputs added in the last hour in the log file. Literally i have nothing yet but:
grep 'Line im looking for' LOGFILE.log | tail -1
this only gives me the last input, but no necessarily from the last hour.
Help Please. (4 Replies)
Hello please help me on this,
pick the last one hour lines from the log, which have the prefix time format like this.
log message
log message
i tried to do grep, but that failed.
my code
grep '(date +)' log_file_path
This checking only the current time stamp. How to get the log... (16 Replies)
I want to extract a pattern from a log file within last hour.
I am doing
grep "pattern" filename | tail -1
It gives the last latest pattern but not within last hour.
and if the pattern found in last hour, output success or else failure. (3 Replies)
Hi, the follow can add the day time to my Log file
My_Log_$(date +%F).log
can I add the hour to the end of my log file then my log file will looks like
My_Log_07-24:(:confused: (3 Replies)
Hi guys
I want any script to get me next hour
For example
Nexthour.sh 2013022823
It get me result
2013030100
Thanks a lot , I'm using Solaris 10 (5 Replies)
Hi friends, I want to convert 24 hour timing to 12 hour please help me...
my data file looks like this..
13-Nov-2011 13:27:36 15.32044 72.68502
13-Nov-2011 12:08:31 15.31291 72.69807
16-Nov-2011 01:16:54 15.30844 72.74028
15-Nov-2011 20:09:25 15.35096 ... (13 Replies)
Hi,
Just wondering, is there anyway I can get the total of logs generated by hours ? Let say I have these logs,
Sep 23 04:48:43 hsbcufs: NOTICE: realloccg /: file system full
Sep 23 04:48:47 hsbcufs: NOTICE: alloc: /: file system full
Sep 23 04:48:51 hsbcufs: NOTICE: realloccg /: file... (14 Replies)
My program:
__________________________________
#!/bin/ksh
DAY=`date +%y%m%d`
H=`date +%H`
M=`date +%M`
day=`date +%m/%d/%y`
let h=$H-1
echo DAY $DAY
echo H $H
echo M $M
echo day $day
echo h $h
_____________________________________
My result: (3 Replies)
set DAY=`date +%y%m%d`
set H=`date +%H`
set M=`date +%M`
mailx -s "$H-Mydata" myemail@mail.com<mydata
I am looking to set the current hour to have 1 hour less in the subject header:
For example: let's say the system time is 8
I want to have "7-Mydata" not "8-Mydata"
Can some1... (6 Replies)