Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Alright, I want to email myself the daily log entries of the /etc/messages log file. What I mean is, for all new lines created on Feb 21, I want them emailed to me on the 22nd. For all new log entries created on Feb 20, I want them emailed to me on Feb 21. Etc...
(I used my real email address in the command line, don't want to post it here for the spammers)
Now this does exactly what I want however I want this done automatically every day. Now I know I can set this up in a cronjob to run at 00:00 every day, but my problem is how do I tell the script to look for "Current Date" in that format? (Three letter month [space] day) I also noticed that if it's a single digit day, then it's (Three letter month [space][space] day)
I also realize that these daily logs could get rather large, especially if a lot was going on that day with the FTP.
BTW, instead of having to wade through all messages manually, how about using Logwatch instead? Logwatch can process all sorts of system and daemon logs, comes with support for several services including FTP daemons out of the box, doesn't need much configuration and can email you alerts daily.
BTW, instead of having to wade through all messages manually, how about using Logwatch instead? Logwatch can process all sorts of system and daemon logs, comes with support for several services including FTP daemons out of the box, doesn't need much configuration and can email you alerts daily.
Google is my friend, I got it installed I think. The README says it should work on it's own, I simply ran the install_logwatch.sh file and it did some stuff, I then changed the default conf file to mail it to my email address, instead of root.
Does it start itself automatically, I don't need to do anything else?
Alright, I want to email myself the daily log entries of the /etc/messages log file. What I mean is, for all new lines created on Feb 21, I want them emailed to me on the 22nd. For all new log entries created on Feb 20, I want them emailed to me on Feb 21. Etc...
This is what I have come up with so far.
less /var/log/messages | grep "$(date --date="yesterday" '+%b %e')" | mail -s "Messages Log Output" myemail@gmail.com
(I used my real email address in the command line, don't want to post it here for the spammers)
Now this does exactly what I want however I want this done automatically every day. Now I know I can set this up in a cronjob to run at 00:00 every day, but my problem is how do I tell the script to look for "Current Date" in that format? (Three letter month [space] day) I also noticed that if it's a single digit day, then it's (Three letter month [space][space] day)
I also realize that these daily logs could get rather large, especially if a lot was going on that day with the FTP.
This no longer works. I've discovered that less /var/log/messages still displays the output, however then I use grep "$(date --date="yesterday" '+%b %e')" nothing is shown. Message is null. I'm guessing "yesterday" is no longer valid. How can I get this to work now?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.