Housekeeping task output triggers emails via anacron #11201

Closed
opened 2025-12-29 21:41:52 +01:00 by adam · 3 comments
Owner

Originally created by @aseques on GitHub (May 20, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.3.0

Python Version

3.10

Steps to Reproduce

With the housekeeping script that's default to netbox install, the script is echoing text to stdout, since all cron's output is redirected to email, I am getting a daily mail with the result of the housekeeping (because I have a mailer configured to my address)

88565e8f68/contrib/netbox-housekeeping.sh (L2)

If the script was outputting to /dev/null it would only sent emails when something is throwing errors, otherwise discard them

/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py housekeeping >dev/null

Another option would be to write the output to a log file:

/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py housekeeping >/var/log/netbox/housekeeping.log

Expected Behavior

There should be only emails when there are errors, otherwise the output should be logged or discarded only.

Observed Behavior

A mail is being sent every time the script is run through crontab

Originally created by @aseques on GitHub (May 20, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.3.0 ### Python Version 3.10 ### Steps to Reproduce With the housekeeping script that's default to netbox install, the script is echoing text to stdout, since all cron's output is redirected to email, I am getting a daily mail with the result of the housekeeping (because I have a mailer configured to my address) https://github.com/netbox-community/netbox/blob/88565e8f680a5b64f1a22b67f007f15acf8f1373/contrib/netbox-housekeeping.sh#L2 If the script was outputting to /dev/null it would only sent emails when something is throwing errors, otherwise discard them > /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py housekeeping >dev/null Another option would be to write the output to a log file: > /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py housekeeping >/var/log/netbox/housekeeping.log ### Expected Behavior There should be only emails when there are errors, otherwise the output should be logged or discarded only. ### Observed Behavior A mail is being sent every time the script is run through crontab
adam added the type: bug label 2025-12-29 21:41:52 +01:00
adam closed this issue 2025-12-29 21:41:52 +01:00
Author
Owner

@pheus commented on GitHub (May 28, 2025):

I'd be happy to contribute this!

@pheus commented on GitHub (May 28, 2025): I'd be happy to contribute this!
Author
Owner

@jeremystretch commented on GitHub (Jun 5, 2025):

This isn't a NetBox bug: The behavior of cron is entirely dependent on how it's configured. The shell script which ships with NetBox is minimal implementation intended to be used by system administrators as a reference. Customization of the task itself it outside the scope of NetBox's documentation.

@jeremystretch commented on GitHub (Jun 5, 2025): This isn't a NetBox bug: The behavior of cron is entirely dependent on how it's configured. The [shell script](https://github.com/netbox-community/netbox/blob/main/contrib/netbox-housekeeping.sh) which ships with NetBox is minimal implementation intended to be used by system administrators as a reference. Customization of the task itself it outside the scope of NetBox's documentation.
Author
Owner

@aseques commented on GitHub (Jun 5, 2025):

Hi @jeremystretch it's more about having a sensible default (that doesn't trigger unnecessary noise), than a bug per se.
Since it's part of the upgrade documentation it get ovewritten on every new release (see here)

@aseques commented on GitHub (Jun 5, 2025): Hi @jeremystretch it's more about having a sensible default (that doesn't trigger unnecessary noise), than a bug per se. Since it's part of the upgrade documentation it get ovewritten on every new release (see [here](https://netboxlabs.com/docs/netbox/installation/upgrading/#6-verify-housekeeping-scheduling))
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11201