Sending newly created log file from suse linux to outlook mail through command line
SUSE / openSUSEThis Forum is for the discussion of Suse Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Sending newly created log file from suse linux to outlook mail through command line
Hello All,
I want to send newly created log file from suse linux to outlook mail box through command line.
In my machine I have configured logrotate for 5 days and I want to send logrotate’s latest output compressed file to outlook mail box every day at 00:30 (as logrotate rotate file at 00:00).
Below is the 5 days file output from my machine.
From these above files I want to send only newly created (latest) file to outlook mail, like in this case I want to send Server_Health_Logs-20150730.gz.
That's a very incomplete solution at best. Much of what you're proposing requires executing the commands manually because nothing supports use inside of a script (there's no variable setting going on and the filename isn't being referenced in any way by a variable).
The correct way to do this would be to use the "postrotate" configuration file option and call a secondary script to locate the file just created and then send it via sendmail. Since the full path to the original log file is passed to the secondary script, it will make it easy to locate the newest file as follows:
find / -amin +2 $1*.gz
The result will be the newest of the compressed files, created within the last two minutes. The original log filename will be passed to the script containing this command, and you'll need to set the result into a variable. Then call sendmail, referencing that variable as the file to attach.
Hello ember1205 and HMW,
Thank u for your concern..
ember1205,
I have tried this below script but its not working. (not sending mail to outlook)
My same code is working on redhat but not in suse.
suse version is:
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1
Try providing the full path to mutt - it won't find it properly otherwise.
Also, your filename "creator" isn't giving it the proper name because there's no inclusion of the ".gz" extension. The parameter that's passed (the ${1} is the original filename of the log that gets rotated, not the newly created file. Honestly, don't know how it is working on RH at all if the code is the same.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.