Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

Cron to send e-mail

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
pote
Asked:
pote
1 Solution
 
StrangeCommented:
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
 
poteAuthor Commented:
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
 
n0thingCommented:
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
 
HalldorGCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now