Help on script to capture info on log file for a particular time frame


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help on script to capture info on log file for a particular time frame
# 1  
Old 04-01-2015
Help on script to capture info on log file for a particular time frame

Hi

I have a system running
Code:
 uname -a
Linux cmovel-db01 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux

I would like to capture the contents of /var/log/syslog from 11:00AM to 11:30AM and sent to this info via email.

I was thinking in set a cron entry at that time to
Code:
tail -f > filename

, them
Code:
mailx

the file, but I am not sure how to stop capturing data at 11:30AM.
Can I have some help on this
# 2  
Old 04-01-2015
Perhaps something like:
Code:
#!/bin/ksh
date=$(date)
tail -f /var/log/syslog > /tmp/loglog.$$ &
tailpid=$!
#echo "tailpid is $tailpid"
sleep 1800
kill $tailpid
mailx -s"30 minute log from $date" user@company.com < /tmp/loglog.$$
rm /tmp/loglog.$$

This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 04-01-2015
Thank you very much, it worked beatifully
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need to filter the result set within 2 time frame

my sample file is like this $cat onefile 05/21/18 13:10:07 ABRT US1CPDAY Status 1 05/21/18 21:18:54 ABRT DailyBackup_VFFPRDAPENTL01 Status 6 05/21/18 21:26:24 ABRT DailyBackup_VFFPRDAPENTL02 Status 6 05/21/18 21:57:36 ABRT DailyBackup_vm-ea1ffpreng01 Status 6... (7 Replies)
Discussion started by: gotamp
7 Replies

2. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

3. Shell Programming and Scripting

Script to capture string in a log file

Dear all, I have a log file to be analysed. this log file contains vaiours lines of code starting with date timestamp. if my search string is exception then that resepective log statement starting from the date is required. example: 2014/10/01 16:14:44.459|>=|E|X|19202496|2832|... (5 Replies)
Discussion started by: shravee
5 Replies

4. Shell Programming and Scripting

awk : collecting all data between two time frame

Hi Experts , I need your help to collect the complete data between two time frame from the log files, when I try awk it's collecting the data only which is printed with time stamp for example, awk works well from "16:00 to 17:30" but its not collecting <line*> "from 17:30 to 18:00" ... (8 Replies)
Discussion started by: zenkarthi
8 Replies

5. Shell Programming and Scripting

Shell Script to delete files within a particular time frame under multiple sub folders

Greetings! I'm looking for starting information for a shell script. Here's my scenario: I have multiple folders(100) for example: /www/test/applications/app1/logs /www/test/applications/app2/logs Within these folders there are log files files that need to be deleted after a month. ... (3 Replies)
Discussion started by: whysolucky
3 Replies

6. Shell Programming and Scripting

How can view log messages between two time frame from /var/log/message or any type of log files

How can view log messages between two time frame from /var/log/message or any type of log files. when logfiles are very big and especially many messages with in few minutes, I would like to display log messages between 5 minute interval. Could you pls give me the command? (1 Reply)
Discussion started by: johnveslin
1 Replies

7. Shell Programming and Scripting

Capture time of File last created.

Hi .. I have a list of filenames in a particular file. All thse files get generated in the same directory. No w i want to find out which of thse got generated last and capture that time . Have written a while loop but seems getting struck ... while read line do if then rvst_capt_time=... (7 Replies)
Discussion started by: ultimatix
7 Replies

8. Shell Programming and Scripting

Script to capture date/time in seconds in PERL... Cant understand errors

I'm Using this script to find the time of a file. I'm very much new to PERL and found this script posted by some one on this forum. It runs perfectly fine, just that it gives me following errors with the accurate output as well. I jus want the output to be stored in another file so that i can... (0 Replies)
Discussion started by: bankimmehta
0 Replies

9. Shell Programming and Scripting

Extract info from log file and compute using time date stamp

Looking for a shell script or a simple perl script . I am new to scripting and not very good at it . I have 2 directories . One of them holds a text file with list of files in it and the second one is a daily log which shows the file completion time. I need to co-relate both and make a report. ... (0 Replies)
Discussion started by: breez_drew
0 Replies

10. UNIX for Advanced & Expert Users

Dynamic time to append for every log info

Hi All, What i am looking for: i want to generate a dynamic system time for each and every data(line) which goes on generating data continously.... now i am using this script to append a time for dynamic data generation log file, tail -f filename_error.log|awk -v var="$( date... (2 Replies)
Discussion started by: gsprasanna
2 Replies
Login or Register to Ask a Question