Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sending an email with attachemtn via cron

Posted on 2014-12-06
4
Medium Priority
?
163 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 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Fine Tune your automatic Updates for Ubuntu / Debian
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

721 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