I want to read the log file for last 30mins logs with time stamps.
Am using below command but, it is not working for me
log file time format is 2016-09-27 14:00:25,192
Moderator's Comments:
Use code tags, thanks.
So you have a log file with a date an time format as produced by the date command:
which give you a string similar to:
and you extract the date field from this string to be just the year by using
and then you compare that to a string produced by the date command:
which gives you output similar to:
which means that your awk command:
boils down to something like:
which will print every line in log.file for which the expression:
evaluates to true (assuming that the date field in log.file starts in column 1 in each line).
Without knowing the format of log.file (specifically where the date appears on each line in that file and what field separator is used to separate the dates in that file from other text in that file, we can't help you solve your general problem. But we do know that you need to use the same format for the strings you are comparing and that you need to compare the same number of fields (i.e., year, month, day, hour, minute, and second need to be compared to year, month, day, hour, minute, and second). Comparing abbreviated month name, day, hour, minute, and second to year cannot possibly select an appropriate 30 minute period.
This User Gave Thanks to Don Cragun For This Post:
Appreciate help for the below issue.
Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt..............
1)if logs exist it should move the logs with extention... (1 Reply)
Hi
We have these specific requirements for a bunch of servers we have and cannot seem to get pam to behave in this way. We would like:
PAM locks accounts if pam tally reaches 10.
PAM unlocks the account after 30mins from locking it, and resets the pam_tally.
The key is that we don't... (0 Replies)
I have 5 log files under different directores . say for eg abc under /home/dir1 , xyz under home/dir2 . is there a script that i can run from say /home that searchers all these files for string or combination of strings and write to a file
eg search file by timestamp|keyword
o/p in a file (6 Replies)
Hello,
I would like to write a bash script that would monitor a log file for a certain number of logs, let's say 500 logs and when it reaches that number to write the last log to another file. For example, I want to watch the /var/adm/messages and everytime, there is 500 new logs that are... (1 Reply)
Hi,
I have a script, running on some outside firwall server and it's log of success or failure is maintained in a file.
I want to write a script which ftp that server and reads that file and checks the logs and if failure , I will send mail notification.
Please let meknow if I am not... (1 Reply)
Ok here is my trouble. I run scripts whenever I am investigating problems. One of those scripts simply goes to a log folder and runs
gzip -cd * | grep error | wc -l
This tells me the number of errors in their log's and how much I should pay attention to them.
The problem is sometimes... (3 Replies)
What is wrong with my menu script? Do I need to continue with the read statements? All I want to do with option 4 is to cat some /var/log/files and awk out a few lines? How do I do that please?
$ cat menu.sh ... (11 Replies)
Hi,
I am trying to write a script which would go search and get the info from the logs based on yesterday timestamp and write yesterday logs in new file. The log file format is as follows:
""""""""""""""""""""""""""... (3 Replies)
Hi All,
I want to run a script on the hour during a 24 - hour period; easy enough cron will take care of that..however I want the script to only run for only 30mins..
so with the script it knows its 30mins are up so exits.
any ideas?
Any help, greatly appericated.
Thanking you all... (2 Replies)
Hi all,
I wrote this script to find files older than time parameter, count the number of files, and send an email to me that some files are in a particular folder. For the particular path, the script should wait delay parameter before running again.
For example, assuming the input file looks... (4 Replies)