-
-
Notifications
You must be signed in to change notification settings - Fork 9
Automated Execution
anon edited this page May 30, 2025
·
1 revision
For continuous monitoring and timely reporting, MailLogSentinel should be configured to run automatically at regular intervals. The use of Systemd timers and services is the recommended method on modern Linux systems. The interactive setup process (--setup) is designed to help you generate template unit files for this purpose.
-
Generated Unit Files (during
--setup): When you run the--setupwizard, it will offer to generate the following Systemd unit files. These files will be saved in the directory where you execute the setup command:-
maillogsentinel.service: This service unit file defines how to run the core log extraction and processing task (i.e., runningmaillogsentinelwithout the--reportflag). -
maillogsentinel-extract.timer: This timer unit file defines a schedule (e.g., hourly) to trigger themaillogsentinel.service. -
maillogsentinel-report.service: This service unit file defines how to run the email reporting task (i.e., runningmaillogsentinel --report). -
maillogsentinel-report.timer: This timer unit file defines a schedule (e.g., daily, typically late in the evening) to trigger themaillogsentinel-report.service.
-
-
Manual Deployment and Activation Steps (User Responsibility):
-
Review and Customize: After the unit files are generated, it is crucial to review them carefully.
- Verify all paths (e.g., to the Python executable, the
maillogsentinelscript itself, and its configuration file specified in theExecStart=line). - Most importantly, ensure the
User=directive in the.servicefiles is set to an appropriate non-root user. This user must have the necessary permissions to read the mail logs and write to MailLogSentinel's working and state directories. - Adjust the
OnCalendar=schedules in the.timerfiles to match your desired frequency for log processing and reporting.
- Verify all paths (e.g., to the Python executable, the
-
Copy to Systemd Directory: Once you have reviewed and (if necessary) edited the unit files, copy them to the Systemd system directory, which is typically
/etc/systemd/system/:sudo cp maillogsentinel.service maillogsentinel-extract.timer maillogsentinel-report.service maillogsentinel-report.timer /etc/systemd/system/
-
Reload Systemd Daemon: Instruct Systemd to read the new (or modified) unit files:
sudo systemctl daemon-reload
-
Enable and Start Timers: To activate the schedules and ensure they persist across system reboots, enable and start the timers:
The
sudo systemctl enable --now maillogsentinel-extract.timer sudo systemctl enable --now maillogsentinel-report.timer
--nowoption starts the timers immediately. IfPersistent=trueis set in the timer unit (which is the default for the generated templates), this may also trigger an immediate run of the associated service if it missed a scheduled run while the timer was inactive. -
Verify Operation: Check the status and next scheduled run times of your timers:
You should see
systemctl list-timers --all
maillogsentinel-extract.timerandmaillogsentinel-report.timerin the output. You can also inspect the logs of the services to ensure they are running correctly usingjournalctl:(Usejournalctl -u maillogsentinel.service -f journalctl -u maillogsentinel-report.service -f
-fto follow the logs in real time).
-
Review and Customize: After the unit files are generated, it is crucial to review them carefully.