Solved

Cron to send e-mail

Posted on 1999-01-21
4
420 Views
Last Modified: 2010-04-21
I need to send e-mail via a cron job.
Basically, I want to have the cron run every Monday, and e-mail a .txt file to a group of people.
I run Linux 5.2
I've tries several crons but no luck.
I could use some help...
Thanks
Pote
0
Comment
Question by:pote
4 Comments
 
LVL 1

Expert Comment

by:Strange
Comment Utility
Add this line to your /etc/crobtab file:
* * * * 1 root /usr/sbin/sendmail aaa@bbb,ccc@ddd < /path/a.txt

then reread cron file by executing
kill -HUP `cat /var/run/cron.pid'

and here we are ! Waiting for results

0
 

Author Comment

by:pote
Comment Utility
The line below sends me a blank mail. It does not pick up the .txt file.
* * * * 1 root /usr/sbin/sendmail aaa@bbb,ccc@ddd < /path/a.txt
Also tried:
* * * * 1 root /bin/cat/ textfile.txt | /usr/sbin/sendmail aaa@bbb,ccc@bbb
Still get a blank e-mail

Help !!
0
 
LVL 5

Expert Comment

by:n0thing
Comment Utility
Perhaps a scripts called mail.sh

#!/bin/sh
/bin/mail abc@def < file.txt
/bin/mail def@abc < file.txt

Although
/bin/mail abc@.def def@abc < file.txt
should also works for the above. The cron file should look like

* * * * 1 /usr/local/bin/mail.sh > /dev/nulll 2>&1
0
 
LVL 7

Accepted Solution

by:
HalldorG earned 150 total points
Comment Utility
Create a script call sendthemondaymail


#!/bin/sh
/usr/lib/sendmail a@b.com c@d.com <<EOF
Subject: Monday mail
From: me@domain.com
To: Mondayreceivers@domain.com

$(cat thefile)
EOF

then and a crontabentry that runs this script
* * * * 1 /pathtoscript/script
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now