Solved

Cron to send e-mail

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

622 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