This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Unable to send e-Mail from crontab in Cygwin
- From: Nem W Schlecht <nemws1 at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 17 Sep 2015 08:59:09 -0500
- Subject: Re: Unable to send e-Mail from crontab in Cygwin
- Authentication-results: sourceware.org; auth=none
- References: <f248e7c31a3cb92535ca59b111b88eea at ufl dot edu>
On Wed, Sep 16, 2015 at 12:43 PM, Shantaraman,Karthik
<k.shantaraman@ufl.edu> wrote:
> Hi,
> I have set up cygwin in my Windows Vista machine and have configured cron by
> running the cygrunsrv command.
>
> I am trying to send an automated mail everyday with cron but it is not
> working out. Could you help me with this?
>
> #Borrowed from anacron
> SHELL=/bin/bash
> PATH=/usr/sbin:/usr/bin
> USER=karthik.techvs@gmail.com
> MAILTO="karthik.techvs@gmail.com"
> #End borrowed from anacron
>
> 15 10 * * * sendmail /USER=karthik.techvs@gmail.com
> "karthik.techvs@gmail.com" testmail
>
>
> I have installed the ssmtp package also after i researched about this
> online.
>
> But it says :
>
> $ ssmtp-config
> -bash: ssmtp-config: command not found
This is, oddly, not very easily found/well documented when you do
Google searches for 'cygwin cron sendmail'.
cron on cygwin installs a symlink to /usr/bin/cronlog as
/usr/sbin/sendmail on installation. This is a good thing. This
script creates a file named 'cron.log' in your home directory for any
cron command outputs. If you look at it, you'll notice many
sendmail-like headers in the file.
To have cron actually send emails, you need to set up
/usr/sbin/sendmail as a link (or a program) to something that actually
sends mails.
I'm using msmtp, but I'm guessing ssmtp will be similar.
Steps:
1) Remove the link /usr/sbin/sendmail
2) Create a new shell script or link in its place
So:
rm /usr/sbin/sendmail
ln -s /usr/bin/msmtp /usr/sbin/sendmail
(Note - use a decent editor instead of cat ... Control-D)
I just installed 'msmtp' on a new install and ran 'msmtp-config'. If
/usr/sbin/sendmail does *not* exist (ie, you install msmpt *before*
cron) then it will create this link for you.
Once you do all this, edit your crontab and put an entry in it like this:
* * * * * date
And reload (if you didn't do a 'crontab -e' to edit)
It may take up to 2 minutes for cron to start doing stuff, as the
minute in runs it'll load in the new crontab and then the *following*
minute, it will run 'date' and should e-mail it to.
Once you start getting e-mails, just comment this line out or delete it.
--
Nem W Schlecht
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple