Cronjob email per virtual server

OS type and version Debian 11
Virtualmin version 7.7


In a different controlpanel, I had the option in the cronjobs section to set the email address where the output should go.

In Virtualmin, I see the output will go to the main user by default.

Is there a way to change this? I thought to add the MAILTO option in the crontab of each user, but the first line clearly states: # DO NOT EDIT THIS FILE - edit the master and reinstall.

Any ideas how to handle this?

1 Like

I’m pretty sure that if you create cronjobs as the domain owner user, the domain owner user will get the emails?

I mean, if you login as a domain owner, you can only create and edit cron jobs owned by the domain owner (unless you grant them full access by adding them in the “Extra Webmin Modules” list) and those cronjobs, I would assume, would send email to the creator of those jobs.

I think they want the cron job result to go to a completely separate email address, eg his personal one. Saves having to check every domain-owner each day.

From Chat-GPT :slight_smile:

If you want to send the output of a specific cron job to a different email address, you can redirect the output of the command to the mail command. Here’s an example:


* * * * * /path/to/your/command | mail -s "Cron job output"

This will send an email with the subject “Cron job output” to “” with the output of /path/to/your/command whenever the cron job runs.

Perhaps add an email-to option?

Please don’t post ChatGPT output (I added this to the guidelines yesterday; it is a bannable offense, if it is posted without clearly noting it is ChatGPT, as we’ve been getting a lot of spammers posting ChatGPT output to gain reputation…and, even if it is labeled, I’d rather we not provide a pipeline for LLM-generated hallucinations directly into the forum).

ChatGPT is not always wrong, but it’s wrong enough of the time and in subtle enough ways that even I sometimes can’t spot it’s wrong until I actually try it or check the docs. People are wrong just as often, but it feels better when people make mistakes, and I feel like we’re better able to judge how much someone knows from other context clues…somehow I’m more easily fooled by ChatGPT than by people, even if the answers are similarly wrong.

It can even be useful. I’ve been doing “pair programming” with it lately, and I’ve gotten useful advice about Google Cloud, but only after some back and forth and experimenting to get it to stop giving me nice sounding hallucinations and start giving me facts. Sometimes, it never gets around to facts. I wasted a lot of time trying to use some Jenkins features that ChatGPT made up.

In short: Don’t post ChatGPT output without trying it and understanding it, first. Then you’ll be able to explain it in your own words. And, you’ll often find out why it won’t actually work the way ChatGPT suggested, and spend some more time finding the way that would work.

1 Like

This works
webmin->scheduled cron jobs->Create Environment Variable
choose a user from the dropdown list and you will see this

just add the email address you want to send to an make sure it’s set to ‘before all cron jobs’. I tend to use it for the root user so I can see the output of root cron jobs but it can be set for any user with any receiving email address set


I like the side discussion about AI, but thank you jimr1 for your solution. I can work with this, simple and clean solution, thanks again!

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.