Change cron default sendmail to mail

I'm running FreeBSD 11.0-RELEASE.

On default cron is using /usr/lib/sendmail to send user emails. How can I tell/set cron to use /bin/mail instead?

crontab(5)() says in the section about the MAILTO var:
This option is useful if you decide on /bin/mail instead of /usr/lib/sendmail as your mailer when you install cron -- /bin/mail does not do aliasing, and UUCP usually does not read its mail.

I downloaded the FreeBSD source code and tried the command # make config in /usr/src/usr.sbin/cron/, that ofc does not work since config is not defined. But I think that's an bad idea anyway cause future updates could easy overwrite this?

Sorry for the noob question, I'm completely new to FreeBSD/Unix.
Thanks for your help!
 
I'm completely new to FreeBSD/Unix.
Welcome!
How can I tell/set cron to use /bin/mail instead?
It looks like this is configured in /usr/src/usr.sbin/cron/cron/config.h - search for MAILCMD. Note that the support for alternate mailers was probably in Vixie cron when it was imported (as opposed to added by FreeBSD) and the arguments in the defines may not apply to / work with FreeBSD. Opening a bug report requesting a way to specify the mailer to be used by cron(8) without recompiling might get somewhere.
I downloaded the FreeBSD source code and tried the command # make config in /usr/src/usr.sbin/cron/, that ofc does not work since config is not defined.
That's correct - # make config is used in ports. For the base system, options (other than kernel configuration) are generally set in make.conf(5).
But I think that's an bad idea anyway cause future updates could easy overwrite this?
That is correct - any non-default base system options will be overwritten by an update that replaces any files that you rebuilt. Normal freebsd-update(8) behavior is to only replace files that changed on the FreeBSD build system(s). An update from 11.0-Px to 11.0-Py (where x and y are two different patch numbers) probably won't replace /usr/sbin/cron. Going between versions, there's more of a chance that it will be replaced.

There are also a variety of alternative cron-type implementations in the ports tree. Note that not everything in that link is an actual cron implementation - the list is just packages that have "cron" in the name in the sysutils category.
 
cron has an upstream: https://github.com/vixie/cron

i'd welcome a patch that allows MAILCMD to be set at runtime. i used _PATH_SENDMAIL because that either *is* sendmail itself, or is a "wrapper script" that properly invokes the necessary postfix foo. but if this is not general enough, let's discuss, and evolve the mail-making machinery. it's not 1986 any more.

note that i have no idea how to get freebsd, or any other distro who imported cron ~20 years ago, to merge against upstream. perhaps fixing bugs and adding features upstream would provide some motivation.
 
cron has an upstream: https://github.com/vixie/cron
[...]
note that i have no idea how to get freebsd, or any other distro who imported cron ~20 years ago, to merge against upstream. perhaps fixing bugs and adding features upstream would provide some motivation.
It is more like 30 years ago - /usr/src/usr.sbin/cron/doc/README says:
Vixie Cron V3.0
December 27, 1993

I guess the question is how much divergence there has been since it was imported, and if using a newer version of cron(8) is likely to cause any breaking changes. That would need to be tested on 12.3, 13.x and HEAD.

I'll throw a note over the wall to the relevant people to get a feel for how likely importing a new version would be. If that's encouraging, I'll take a look at it, unless I hear that someone else has been working on it. OTOH, my reply just above yours is 5+ years old, so I don't know how much interest there is for this. Perhaps if the idea of removing sendmail from base gains traction again (the last major discussion seems to have been from 5 years ago, and it is still in HEAD) this might become more relevant.

Another, probably safer alternative would be to add a WITHOUT_CRON knob to buildworld and then add a port for Vixie cron.
 
Top