- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how can i get last 10 lines of a log mailed to...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2004 08:56 PM
тАО02-15-2004 08:56 PM
I would like to set up an automated e mail sent to myself which would contain the last 10 lines of the daily report.
whats the best solution?
My train of thought is going crontab, mailx
but I dont know the correct syntax to set it up...
cheers for any help out there
Bob
Happy Monday to yer
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2004 09:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2004 09:03 PM
тАО02-15-2004 09:03 PM
Re: how can i get last 10 lines of a log mailed to me?
a.sh would contain
mailx -s "Daily report" bob@bob.com < `tail -10 dailyreport.txt`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2004 09:54 PM
тАО02-15-2004 09:54 PM
Re: how can i get last 10 lines of a log mailed to me?
so far Im receiving an e amil which is great but there is no data or any text at all in the e mails body
any chance you could break down each part of the line please
cheers
bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2004 10:05 PM
тАО02-15-2004 10:05 PM
Re: how can i get last 10 lines of a log mailed to me?
TGM method should work also, but hust tried my own.
03 12 * * 1-5 /usr/bin/tail -10 /var/adm/syslog/syslog.log | /usr/bin/mail myname@Foo.com 2>&1
worked good.
Regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2004 02:43 PM
тАО02-16-2004 02:43 PM
Re: how can i get last 10 lines of a log mailed to me?
Here is something I wrote regarding this to answer an earlier question. Rather than edit the previous post (It's starting to feel pretty late in the day), just insert the "/usr/bin/tail -10 /var/adm/syslog/syslog.log" command as needed. I only wanted to include this in the thread since it also incorporates the use of the subject field, and provides a different way to do this. I'm pretty sure there are cleaner methods, but this is one I have used, and works rather well.
Good Luck,
Chris
*** previous entry ***
The cron command should look like this:
/usr/sbin/ioscan -fnC lan > /tmp/ioscan.out ; elm -s "Subject of Message" username@companyname.com < /tmp/ioscan.out ; rm /tmp/ioscan.out
Because of the need for the subject line, the elm command was used. This along with the redirection of the command line will work with most commands, as long as the full path is specified.
If you would like to get the result of a command like "date" in the subject field, command
substitusion can be used. Make the line look like this:
/usr/sbin/ioscan -fnC lan > /tmp/ioscan.out ; elm -s "Subject of Message `date`" username@companyname.com < /tmp/ioscan.out ; rm /tmp/ioscan.out
A tick, not a single quote, surrounds the date command. The tick is usually the character under the tilde (~) symbol on the keyboard. You can also use other commands such as `hostname` for even more description.
So to add a cron job of the "who -R" command to send an e-mail every hour to the root account of abc.com with the subject that included the current date, you would edit the crontab file as follows:
# crontab -e
then add:
0 * * * * /sbin/who -R > /tmp/who.out ; elm -s "Who output for `date`" root@abc.com < /tmp/who.out ; rm /tmp/who.out