Regarding mailing of logs


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Regarding mailing of logs
# 1  
Old 05-29-2012
Question Regarding mailing of logs

Hi Folks ,

I have one query I traverse to a location where logs are being made daily, Now I want that a particular log in that logs directory to be get mailed to me automatically at a particular time on daily basis at my mail id, Please advise the command for that..

for ex the directory is
Code:
cd /var/log

and in that there are several logs..
HTML Code:
abc.log
xyz.log
ert.log
I want abc.log to be get mailed to me at my email id saraldly@gmail.com in the evening
# 2  
Old 05-29-2012
Think about this as two steps

1. Create a unix script to email you the file. Perhaps something using mailx command.
see --> mail with attachments
2. Then, create a cron entry to execute the script at a set data and time.

Last edited by joeyg; 05-29-2012 at 12:54 PM..
This User Gave Thanks to joeyg For This Post:
# 3  
Old 05-29-2012
Hi joeyg,
Thanks a lot for giving pointers, but I am new bie , what I grasp is that..
My location is
Code:
cd /var/logs/abc.log

so by reaching to this location
Code:
uuencode abc.log | mailx -s "logs requested" sankalps@192.28.124.89

Please advise till this it is correct..!!
# 4  
Old 05-29-2012
Couple things to consider

Code:
cd /var/logs/abc.log

will error. should
Code:
cd /var/logs

as you change directories, and should not include filename

Now, since a cd command could error, probably better to change you 2nd line to

Code:
uuencode /var/logs/abc.log | mailx -s "logs requested" sankalps@1somewhere.com

Try it out at the command line (on your screen).
If ok, then you would type this into a file and save it as something like email_logs.sh
Will need to make the script executable
Code:
chmod +x email_logs.sh

Finally, you can work on the cron tast to run this regularly.
This User Gave Thanks to joeyg For This Post:
# 5  
Old 05-29-2012
Hi joeyg,
Thanks a lot, Perfect explanation for a beginner , please advise

1) I do not any more need to do the cd command to reach the location , when I login through putty I am at the root , at this I should go as per your advise command

Code:
uuencode /var/logs/abc.log | mailx -s "logs requested" sankalps@1somewhere.com

Now if first I should try this command , if it works then it would immediately mail me abc.log at my inbox on sankalps@1somewhere.com
# 6  
Old 05-29-2012
Yes, try the command to see what happens.
If it works, great.
If not, then will need to see what might be wrong; including mail not running on your unix box.
This User Gave Thanks to joeyg For This Post:
# 7  
Old 05-29-2012
Hi Joeyg,
Thanks a lot for the explanation , I will try tomorrow as rite now I don't have remote access to Unix machine and then will definitely will let you know. could you also please advise me in advance if this does not work then how can I configure the mail so that Mail can run on unix box machine also..!!

---------- Post updated at 11:57 AM ---------- Previous update was at 11:53 AM ----------

Hi Joeyg,

Please also advise , If the commands executed succesfully and I have made an .sh file named email_logs.sh and also done the permissions settings, Now I want this file to be at my inbox say after every 6 hours , Please advise what crontab setting I need to do.Thanks in advance.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

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)
Discussion started by: Sanjeev G
1 Replies

2. UNIX for Advanced & Expert Users

Regarding mailing of logs

Hi Folks, I have an application which logs get continuously refreshed and made after every 1 second , I want that those logs get mailed to me at my email id sara@somewhere.com The location is cd /var/log/abc/log Please advise the command so that I can mail abc.log at my mailid inbox... (2 Replies)
Discussion started by: SankalpS
2 Replies

3. Shell Programming and Scripting

Mailing Script

Hi, I am totally New to This Scripting Area.We have developed some reports in Bo and User need those reports to be sent through Unix Server (SFTP). Can any one provide me script for transfering File from one location to other with the requirement like if that file fails to reach destination... (4 Replies)
Discussion started by: Sashanth_S
4 Replies

4. UNIX for Dummies Questions & Answers

Mailing in unix

is there any option to mail the value from top command directly to the user.. i want the value of cpu usage from six different servers to be send in a single mail.. thanks, Arun Manas:b: (3 Replies)
Discussion started by: arunmanas
3 Replies

5. Shell Programming and Scripting

HTML mailing

Hi All, I have a comma separated file as below. file-1 ---------- a,b,c d,e,f g,h,i . . . I want to send the above file in Mail in HTML format with all the values of each column in separate cells i.e. the body of the mail should be in tabular format & each field should be separate... (2 Replies)
Discussion started by: 46019
2 Replies

6. Shell Programming and Scripting

issue with mailing

hi i run a mailing script daily using rsh i receive the mail sometimes but sometimes receive the permission denied error. could not understand the cause of permission denied because it sometimes runs properly and i am able to receive the mail Please Advice (4 Replies)
Discussion started by: mad_man12
4 Replies

7. Shell Programming and Scripting

Mailing script

Hi, I have a file lets say FILE1. FILE1 ------ name,age charlie,25 harry,29 david,32 Pls help me writing a mailing script.... which will mail the content of file in the body of the mail & it will look something like below in two columns. name age charlie 25 harry 29... (1 Reply)
Discussion started by: 46019
1 Replies

8. Shell Programming and Scripting

Grep yesterday logs from weblogic logs

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)
Discussion started by: harish.parker
3 Replies

9. UNIX for Dummies Questions & Answers

Mailing an attachment

Hi, I need to compress (zip) a flat file and mail the same as an attachment. I had tried the following piece of code. But when i open the attachment in mail, the data is incorrect (displays all junk characters). tar cf abc.tar abc.txt compress abc.tar uuencode abc.tar.Z abc1.wri | mailx... (4 Replies)
Discussion started by: gayath3
4 Replies

10. UNIX for Dummies Questions & Answers

Mailing an attachment

Hi, I'm fairly new to using Unix and I was just wondering can someone please tell me the simplest way to mail and attachement using the mail command using Solaris? I have tried using uuencode file name | mail johndoe@ttp.ie but it hasn't worked. I have been mailing the file to myself using... (4 Replies)
Discussion started by: gerwhelan
4 Replies
Login or Register to Ask a Question