Solved

Cron to send e-mail

Posted on 1999-01-21
4
423 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
ID: 2009336
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
ID: 2009337
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
ID: 2009338
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
ID: 2009339
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

863 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

19 Experts available now in Live!

Get 1:1 Help Now