Fcron.daily script with sendmail

I have dropped a script (run speedtest) into the fcron.daily directory, which includes piping results to sendmail. It’s a simple one-line bash script to run speedtest and email the results.

(echo -e "Subject: Speedtest Result"; echo; speedtest -s 23971) | sendmail -f admin1@domain admin2@domain

If I run the script manually (from the fcron.daily directory), I receive the email with the results of speedtest. However, when fcron runs the script I receive a blank email. I moved a copy of the script to the minutely directory for testing and received blank emails from there as well.

The script is partially working (subject is correct as is from/sender email), but I really need the results to be in the email. Any ideas how to fix it?

Thanks in advance.

If you can manually run a script but it has problems when run via fcron then often this is due to ownership issues for running the command or sub commands.

The likely issue is that the scripts in the fcron.daily etc directories are not being run as user root but as another user such as cron etc.

When you manually run the script you are doing so as root.

When fcron runs the script it is running it as another user but sendmail requires root ownership for it to be run.

Additionally any ownerships implicit in scripts often do not get applied across pipes.

Maybe try running the bash script with sudo but as you have a pipe there it might be that you need to run sudo -s first and then run the script.

Also worth looking at this documentation on running fcron for custom scripts.

1 Like

I see the docs mention the same path issue that cron has in that the paths don’t carry necessarily across into scripts. It can be got round, as the docs say, by giving the full path to the executable. Alternatively you can use the shebang #!/bin/bash -l with the -l making bash behave as if the user had logged on.

1 Like

I set up the fcronuser per the documentation and used the example fcrontab which included running speedtest. The only difference is I added the MAILFROM and MAILTO variables at the beginning of the crontab. There is nothing in the CRON logs (log is blank, so maybe I need to enable?) that the command executed successfully. However, there is something wrong with dma as the crontab entries for fcronuser produce the following errors in the Mail log.

I do have “Mail Service” configured and working (test mails received with no issue, plus sendmail via root works), so not sure why the mails are stuck. But there must be something else that needs configured for using dma with fcron. Open to ideas.

I’ll continue to run manually and troubleshoot, but I wish there was msmtp or something similar available (I’ve never compiled from source and want to minimize changes to ipFire).

But mailing works, doesn’t it? You are receiving an empty email. It means the message going to the email is failing, either from the echo command or the speedtest command, doesn’t it?

1 Like

yes, mail works. If I run the command directly (via ssh), I receive the expected email. It has something to do with cron/fcron permissions to send mail.

Right now, /var/spool/dma has a number of spooled messages, which are basically 550 errors (sender verification failed) because the emails are getting sent/enveloped from root@[ipfirehostname.mydomain]. fcron/cron is ignoring the MAILFROM setting in the crontab.

I’ve looked at the dma configuration on ipFire, and everything is set correctly, from what I can tell (i.e., correct from/to envelopes, authorization, etc.). But for some reason fcron/cron is ignoring that information.

This post thread could be useful as it covers sending emails from apcupsd via dma while the apcupsd docs are based on sendmail and there are differences.

Maybe what worked for apcupsd will also be useful for your situation.


It was very useful, thanks. I created a non-root user (in sudoers group to access sendmail) and received the intended email. The nobody user was an oversight as I did see that in the dma directory permissions.

Unfortunately, I’m still unable to automate as cron is not reading the fcrontabs of my users. I confirmed cron is a running service, but the times come and go in fcrontab with no activity. I even have a simple command to touch a file (& 12 * * * * /usr/bin/touch /mnt/speedtest-results/test) to eliminate mail issues, but no joy (/mnt is 755 and speedtest-results is 777 so there shouldn’t be a permissions issue).

I guess I need to open a new thread to figure out why fcrontab files aren’t getting read.

I seem to remember having a period where none of the scripts I had in my fcronuser fcrontab were getting run. Unfortunately it is long enough ago that I can’t remember what was needed to fix it.

However, what I do know is that what is in the fcron documentation is working on my production system.

Quick check, you did add the new fcronuser you created to the /etc/fcron.allow file. If you didn’t, or the user name has a typo then the fcrontab will not be executed.

If that is okay then I would follow the Troubleshooting section in the IPFire fcron documentation page.

You can make fcron print its output to log and even increase the verbosity with a debug flag.

Hopefully that should tell you what is stopping things happening when the set time passes.

1 Like

Not knowing frcon, but with cron, it is very picky about file names and I know some distros like Ubuntu don’t allow a period in the file name whereas others do. Also scripts would refuse to run unless the end-of-file was on a new line. (cat the file and see where your prompt ends up)

@ernieg92 ,
have you tried with the full name of speedtest, /usr/bin/speedtest vs. speedtest ?
The latter depends on the setting of the PATH variable.

I did confirm that yesterday, still not sure why it’s not working.

Well, the -y flag explains why there is nothing in the cron log. I turned it off. Fingers crossed to hopefully find a solution.

I did make sure EOF was at the end (along with full paths). But thanks for the tip!

Thank you all for your assistance. I’ve finally got fcron working correctly!

Biggest culprit: creating a non-login user (fcronuser) to run the script. Because I’m using the Ookla version of SpeedTest (provides more detail, more options), it requires acceptance of the license. Since there was no shell or home directory, I was continually getting blank results. Once I gave the user a shell and password, I was successful multiple times (have since returned to /bin/false for fcronuser).

There are also some minor quirks to fcron (which could be updated on the ipFire documentation). For example, you can’t take a nice, clean text file (with proper arguments and syntax) and use that for the fcrontab. Apparently, the extra non-ASCII characters are needed for fcron to work properly. These log entries clued me in:

fcron[30135]: This file may have been generated by an old version of fcron.
fcron[30135]: File fcronuser is not valid: ignored.
fcron[30135]: adding file fcronuser

Removing the -y in the fcron init.d was monumental (thanks for the tip, Adolph), which finally led me down the correct path.


  • Enable cron/fcron logging (remove -y from loadproc command /etc/rc.d/init.d/fcron)
  • Review errors in cron log
  • Change one thing at a time until success
  • Make sure syntax in fcrontab is correct as it does differ some from crontab
    (Also, change default fcrontab editor to nano, to make things simple)
  • Don’t use standard text file to edit fcrontab (copy/paste into editor invoked by fcrontab -u USER -e)
  • Test multiple times in different scenarios
  • Disable cron logging when finished (add -y to loadproc command /etc/rc.d/init.d/fcron)

Sorry for the long post but, again, thank you for helping this (mediocre) coder out!

1 Like