Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I am a new learner in Linux, I work in AWS Cloud, We have bunch of AWS Linux Servers, where we have used cron utility for patch update on all the linux servers.
Can someone please provide me the setup or the configuration on how can I receive an email notification once the update has been done.?
Below is the current setup I have and the log gets generated at /tmp/yum_updates.log, Once the upgrade is done,I would like to receive an email notification.
How this can be achieved.
========================================================
Every Tuesday at 02:30 AM GMT patches get installed.
Change your cron job to a script that does the yum update and then either cat the resulting log file in to sendmail where you'll get the log as the body of the message or install and use mutt which makes it easier to send the log file as an attachment.
Just remember that AWS EC2 instances have mail levels throttled to a small amount of e-mails per instance per day, unless you use SES SMTP as a relay.
If you have a inbound email relay, you can allow it (via the access table) and just forward your email using postfix and relay configuration.
Since this mail is bound for your mail domain, it can be accepted without too much checking.
If you have a email service, you might have to adhere to their rules that prevent spam. Things like STARTTLS, spf, dkim, dmarc. The days of spinning up an autonomous mail server running on port 25 that delivers everywhere are over.
1 ) I find it difficult to implement this. Would you mind providing me a sample script for the update with the email notification ?
Sure, my consultancy rates are $200/hr.
Try it yourself and post what you've tried and where the problems are.
I'm happy to help, but you need to put some learning effort into this too.
Quote:
Originally Posted by Avinash Yadav
2) Would it be possible to edit the file which I already have with email notification ? If Yes, where and how to implement?
Sure, you could just append the mail part to your existing one line cron entry using ; to delimit commands. However, a three line script is much easier to maintain.
1. The sendmail, and postfix commands can be used to send mail from the command line.
2. The cron job will operate on the command line, usually.
3. Look at "man 5 crontab".
As an added bonus, something I used to do, is send wol commands to computers, which you can find the wol program somewhere out there. It can be used to make a schedule for servers, so they do not have to run 24/7.
As an added bonus, something I used to do, is send wol commands to computers, which you can find the wol program somewhere out there. It can be used to make a schedule for servers, so they do not have to run 24/7.
Less relevant to the OP as they mention they are using AWS, so I'm assuming EC2 instances that can be scheduled to start / terminate if required.
You need to setup the postfix relay first, or it won't work. If you've done that and it works it is simple.
Getting the mail in, as I said, is the easy part. Here is a cron I just installed in cron. (I prefer to put the script name call in cron so you don't have to funny crontab problems and can run it to test easier):
I did tried to send an email to my ID, The logs says the message is sent OK, but unfortunately I did not receive any email. I checked my spam folder as well. What could be the issue ?
Feb 3 02:50:08 ip-10-238-194-57 postfix/cleanup[26089]: B889AC57180: message-id=<20230203025008.B889AC57180@ip-10-238-194-57.eu-west-1.compute.internal>
Feb 3 02:50:08 ip-10-238-194-57 postfix/qmgr[1339]: B889AC57180: from=<root@ip-10-238-194-57.eu-west-1.compute.internal>, size=533, nrcpt=1 (queue active)
Feb 3 02:50:15 ip-10-238-194-57 postfix/smtp[26092]: B889AC57180: to=<avinash.yadav@netenrich.com>, relay=mx2-us1.ppe-hosted.com[67.231.154.163]:25, delay=6.8, delays=0.04/0.04/6.5/0.23, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 64986440061)
Feb 3 02:50:15 ip-10-238-194-57 postfix/qmgr[1339]: B889AC57180: removed
====================================
Also I edited the script as below what was suggested in this thread. Sorry my linux skills are just too bad.
There is a thing called spf records. Your mail relay might need to have this updated in DNS. These are the ips in which mail is expected to originate, which is now your AWS instance. I'd check whoever runs your email, you might have bounced but it might not deliver back to you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.