Solved

Sending an email with attachemtn via cron

Posted on 2014-12-06
4
158 Views
Last Modified: 2014-12-14
Hi,

I want to send a txt file as an attachment via a cron command.

/usr/lib/sendmail email@domain.com < /path/to/file.txt

When I use the following command, the contents of the file are in the body and it is not an attachment.

How can I have the text file be an attachment?

Thanks!
0
Comment
Question by:Computer Guy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Author Comment

by:Computer Guy
ID: 40484696
This is a log file I want to email so I can view the errors if they occur. I want it sent once an hour which I have setup if that helps.
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40484773
try this

 /usr/bin/uuencode /path/to/file.txt  file.txt | /usr/lib/sendmail email@domain.com

This will send /path/to/file.txt as attachment "file.txt"
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40484774
Please add above as crontab job. Do you need help in that?
0
 
LVL 35

Accepted Solution

by:
Seth Simmons earned 500 total points
ID: 40484965
i had issues with uuencode; found mutt to work better

mutt -s "subject" -a filename.tar.gz user@domain.com < message-body.txt

if not installed, do yum install mutt (fedora/red hat/centos) or apt-get install mutt (debian/ubuntu/mint)
0

Featured Post

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question