Solved

Cron to send e-mail

Posted on 1999-01-21
4
424 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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.

831 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