i try to change my system to send weekly spam reports

Jun 17, 2022
30
2
13
systemctl edit pmgspamreport.service
Code:
### Editing /etc/systemd/system/pmgspamreport. service. d/override.conf
### Anything between here and the comment below will become the new contents of the file
[Unit]
Description=send weekly spam report mails
ConditionPathExists=/usr/bin/pmgqm
[Service]
Type=oneshot
ExecStartPre=-/usr/bin/pmgqm purge
ExecStart=/usr/bin/pmgqm send --timespan week
### lines below this comment will be discarded
###/lib/systemd/system/pmgspamreport.service
# [Unit]
# Description=Send Daily Spam Report Mails
# ConditionPathExists=/usr/bin/pmgqm
# [Service]
# Type=oneshot
# ExecStartPre=-/usr/bin/pmgqm purge
# ExecStart=/usr/bin/pmgqm send --timespan yesterday

Now i got everyday a "daily spam report" plus a "weekly spam report"

But my goal is a "weekly spam report" every monday morning and no more "daily spam report"

What must i change to
1. disable daily reports
2. enable weekly reports
 
Usually you need to adapt the timer unit as well
Code:
systemctl edit pmgspamreport.timer
in addition to the service
see `man systemd.timer`

I hope this helps!
 
i change this too and hope it works

systemctl edit pmgspamreport.timer

Code:
### Editing /etc/systemd/system/pmgspamreport.timer.d/override.conf
### Anything between here and the comment below will become the new contents of>
[Unit]
Description=Send Weekly Spam Report Mails

[Timer]
OnCalendar=Mon *_*_* 05:00:00
Persistent=true

[Install]
WantedBy=timers.target

### Lines below this comment will be discarded

### /lib/systemd/system/pmgspamreport.timer
# [Unit]
# Description=Send Daily Spam Report Mails
#
# [Timer]
# OnCalendar=00:05
# Persistent=true
#
# [Install]
# WantedBy=timers.target
 
What's the output of :
* systemctl cat pmgspamreport.timer
* systemctl cat pmgspamreport.service
?
 
systemctl cat pmgspamreport.timer

Code:
# /lib/systemd/system/pmgspamreport.timer
[Unit]
Description=Send Daily Spam Report Mails
[Timer]
OnCalendar=00:05
Persistent=true
[Install]
WantedBy=timers.target

# /etc/systemd/system/pmgspamreport.timer.d/override.conf
[Unit]
Description=Send Weekly Spam Report Mails
[Timer]
OnCalendar=Mon *_*_* 05:00:00
Persistent=true
[Install]
WantedBy=timers.target

systemctl cat pmgspamreport.service

Code:
# /lib/systemd/system/pmgspamreport.service
[Unit]
Description=Send Daily Spam Report Mails
ConditionPathExists=/usr/bin/pmgqm
[Service]
Type=oneshot
ExecStartPre=-/usr/bin/pmgqm purge
ExecStart=/usr/bin/pmgqm send --timespan yesterday

# /etc/systemd/system/pmgspamreport.service.d/override.conf
[Unit]
Description=Send Weekly Spam Report Mails
ConditionPathExists=/usr/bin/pmgqm
[Service]
Type=oneshot
ExecStartPre=-/usr/bin/pmgqm purge
ExecStart=/usr/bin/pmgqm send --timespan week
 
And now, how can i disable these default configs?

Code:
# /lib/systemd/system/pmgspamreport.timer
# /lib/systemd/system/pmgspamreport.service
 
If you provide more than one OnCalender event they are triggered each - see the manpage of systemd.timer
and maybe the following post on stackoverflow:
https://stackoverflow.com/questions...to-clear-an-entry-when-overriding-a-unit-file

add to your override:
Code:
[Timer]
OnCalendar=
OnCalendar=Mon *_*_* 05:00:00
Persistent=true

similarly I think you also need to reset the ExecStart line in the .service definition

I hope this helps ...
 
Yesterday I commented out all the lines in both files.
Code:
/lib/systemd/system/pmgspamreport.timer
/lib/systemd/system/pmgspamreport.service

systemctl cat pmgspamreport.timer shows the following:
Code:
# Warning: pmgspamreport.timer changed on disk, the version systemd has loaded is outdated.
# This output shows the current version of the unit's original fragment and drop-in files.
# If fragments or drop-ins were added or removed, they are not properly reflected in this output.
# Run 'systemctl daemon-reload' to reload units.

No daily or weekly spam reports were received today.
That's fine, I'll wait for Monday.

But I can't understand why this can't be easily set via the web interface.
Code:
[x] weekly spam report on
(o) Monday
(_) Tuesday
(_) Wednesday
(_) Thursday
(_) Friday
(_) Saturday
(_) Sunday
 
  • Like
Reactions: Nico109
But I can't understand why this can't be easily set via the web interface.
Because it is not asked too often - and the modifications are not too hard to do on the commandline