How to enable fcrontab mail notifications

In Ubuntu and other distros I use crontab for maintenance scripts, and I get notified of errors by email. Basically this is what’s needed (as simple example):

The user’s crontab:

$ crontab -u some-user -l

*/1 * * * * /usr/bin/echo "Be alert!"

The user’s alias:

$ grep 'some-user' /etc/aliases

some-user: admin@some-domain.com

I’m having a very hard time trying to get this working in IPFire. The mail setup in the GUI works fine.

I can also send mail from CLI. As an example:

echo 'Subject: Important!' | sendmail admin@some-domain.com

Works as expected. I get the mail.

But the following fcrontab won’t send any mail:

$ fcrontab -u some-user -l

MAILTO="admin@some-domain.com"
*/1 * * * * /bin/echo "$(date)" >> /tmp/test; /bin/echo "Be alert!"

The file /tmp/test gets the date every minute. And the second command should send an email, but nothing happens.
There is nothing in /var/log/mail or /var/log/messages.

I already checked www.ipfire.org - fcron
The commands are being run, but no email is being sent. Not even to the running user or root.

What else should I do to make this work?

You are applying the crontab syntax to fcrontab. While some commands etc are the same or similar others are not.

You should read the fcron documentation on fcrontab

fcron.free.fr/doc/en/fcrontab.5.html

You can search for all the instances of mailto

Examples that might help are in the sections labelled

Example 2-1. Some examples of lines based on elapsed system up time
Example 2-2. Some examples of entries based on time and date

You will need to understand about the use of options in fcron and whether they need to start with @, & or % depending on the type of time command being run. If no options are being defined then @, & or % are not needed.

I have not used the fcron mail commands myself so cannot help with explicit suggestions.

Corrected link to fcrontab docs.
-Bernhard

1 Like

Thanks for the answer.

If your are referring to the use of MAILTO, it’s allowed according to documentation:

Additionally, the special variables MAILFROM and MAILTO allow you to tell fcron from/to whom it should email the command’s output. Note that these are in fact equivalent to global declarations of the options mailfrom and mailto (see below). They are used for backward compatibility, and it is recommended that you use the options mailfrom and mailto directly instead.

But anyway. I have already tried using &mailto. This is also not working:

&mailto(root) * * * * * /bin/echo "$(date)" >> /tmp/test; /bin/echo "Be alert!"

This should at least send an email to user root and show it in /var/mail/root and show logs in /var/log/mail, but nothing, not even errors.

Remember that the commands are being run, but no email is being sent.

I have tried a lot of combinations, for example:

&mailto(root)
&mailto(root),forcemail
&mail,forcemail,mailto(root)
&mailto(admin@some-domain.com)

Does fcron or fcrontab have log files somewhere?

Are you able to see the system trying to send mail in /var/log/mail with a simple crontab? like:

&mailto(root) * * * * * /bin/echo "Be alert!"