Feature #9172

Use anacron for automatic emails on 1st of month

Added by sajolida 2015-04-07 16:58:55 . Updated 2015-09-03 05:11:00 .

Status:
Rejected
Priority:
Normal
Assignee:
Category:
Infrastructure
Target version:
Start date:
2015-04-07
Due date:
% Done:

100%

Feature Branch:
Type of work:
Sysadmin
Blueprint:

Starter:
Affected tool:
Deliverable for:

Description

We currently use crontab to send email reminder for monthly meetings and low-hanging fruit sessions. If the machine is down, then the reminders are not sent. Using anacron would solve such an issue for the reminder sent on the 1st of month (but not for the ones sent on day 10 and 15).


Subtasks

Feature #9173: Install anacron on [misc] Resolved

100


History

#1 Updated by intrigeri 2015-07-12 03:14:14

I completed the only subtask. Anything left to do, or shall we close this ticket?

#2 Updated by sajolida 2015-08-10 05:42:18

Now I need to configure that stuff.

#3 Updated by sajolida 2015-08-11 07:08:25

  • Assignee changed from sajolida to intrigeri

It seems like, the jobs need to be added to /etc/anacrontab to which I don’t have access. Can you please feed it with:

@monthly    15  lhf-session LHF=$(date --date="$(date '+%Y-%m-12')" +%F) ; ruby ~sajolida/meeting/meeting.rb --locale en_US.UTF-8 --template ~sajolida/lhf.eml --date $LHF --subject "TESTING ANACRON -- Low hanging fruit session: $(date --date=$LHF '+%A %B %d')" --from sajolida@pimienta.org --to sajolida@pimienta.org
@monthly    15  monthly-meeting MONTHLY=$(date --date="$(date '+%Y-%m-03')" +%F) ; ruby ~sajolida/meeting/meeting.rb --locale en_US.UTF-8 --template ~sajolida/monthly.eml --date $MONTHLY --subject "TESTING ANACRON -- Tails contributors meeting: $(date --date=$MONTHLY '+%A %B %d')" --from sajolida@pimienta.org --to sajolida@pimienta.org

If this works fine one or twice we can then put it in production. I worried about two things:

  • When the first job will be run. If it’s run today then the reminders will be wrong and not at the time we want them to be triggered.
  • Whether anacron uses the same escaping as cron for commands. The man page says nothing about it but we never know…

Feel free to reassign this to bertagaz if he’s the one on duty.

#4 Updated by intrigeri 2015-08-26 01:22:11

  • Assignee changed from intrigeri to sajolida
  • QA Check set to Ready for QA

sajolida wrote:
> It seems like, the jobs need to be added to /etc/anacrontab to which I don’t have access. Can you please feed it with:

Done. Let us know how it goes.

> * Whether anacron uses the same escaping as cron for commands. The man page says nothing about it but we never know…

Does it mean that the changes you’re proposing were not tested?

#5 Updated by intrigeri 2015-08-26 01:24:19

  • Status changed from Confirmed to In Progress

#6 Updated by sajolida 2015-08-26 06:13:15

> Does it mean that the changes you’re proposing were not tested?

Yes, I have no root access on computers that are online enough to test
this. Maybe I could have tried directly from Tails…

#7 Updated by intrigeri 2015-08-26 06:43:26

> Yes, I have no root access on computers that are online enough to test this. Maybe I could have tried directly from Tails…

FYI, just so you know next time: I doubt that root access is required to test this. You can pass a custom anacrontab to the anacron command, and run it from your personal crontab.

#8 Updated by sajolida 2015-09-02 04:34:10

  • QA Check changed from Ready for QA to Dev Needed

I didn’t receive these emails :(

If I understood correctly anacron is designed to be used by root, and not other users. Still, there are workarounds and how-to on how to do that, like http://www.it.uc3m.es/marcos/doc/miniHOWTOs/miniHOWTO-Use_anacron_as_non-root_user.html.

Honestly, this whole story sounds like overengineering to me given the corner case we’re trying to improve upon, and I’ve lost fun a while ago…

#9 Updated by intrigeri 2015-09-02 07:47:34

> I didn’t receive these emails :(

Even last week?

$ sudo cat /var/spool/anacron/{lhf-session,monthly-meeting}
20150826
20150826
/var/log/syslog.6.gz:Aug 26 07:51:53 misc anacron[21773]: Job `monthly-meeting' started
/var/log/syslog.6.gz:Aug 26 07:51:53 misc anacron[21773]: Job `monthly-meeting' terminated
/var/log/syslog.6.gz:Aug 26 07:51:53 misc anacron[21773]: Job `lhf-session' started
/var/log/syslog.6.gz:Aug 26 07:51:53 misc anacron[21773]: Job `lhf-session' terminated

… so I bet that it won’t run these jobs again before September 26, if I understand correctly how anacron is supposed to work.

I’ve deleted /var/spool/anacron/{lhf-session,monthly-meeting}, and now I’m told:

Sep  2 07:36:23 misc anacron[31256]: Will run job `lhf-session' in 15 min.
Sep  2 07:36:23 misc anacron[31256]: Will run job `monthly-meeting' in 15 min.

So perhaps anacron is not what we need, as it lacks calendar time precision, and only cares about frequency. Sorry, I’m probably the one who suggested it initially.

One solution would be to have the cronjob handles the scheduling/frequency details itself in a way that is robust against shutdown times (e.g. have a daily cronjob running, that checks some marker file’s mtime to see if the email have been sent yet, and if not starts the program that handles this and then touch’es the marker file). But it seems that systemd has exactly the functionality we need, that we could use in a declarative way — if curious, see the systemd.timer(5) manpage, in particular OnCalendar= (to specify when the unit shall be run) and Persistent= (that allows to “catch up on missed runs of the service when the machine was off”).

> Honestly, this whole story sounds like overengineering to me given the corner case we’re trying to improve upon, and I’ve lost fun a while ago…

Well understood. I could possibly give a try to the systemd.timer solution I’m mentioning above, one of these days, as a nice way to procrastinate and to learn more about systemd.

#10 Updated by sajolida 2015-09-03 05:10:30

> Even last week?

Yes, the only emails I received with “TESTING ANACRON” in the subject
were from August 11:

Date: Tue, 11 Aug 2015 06:59:07 -0700
From: sajolida <sajolida@pimienta.org>
To: sajolida@pimienta.org
Subject: TESTING ANACRON -- Tails contributors meeting: Monday August 03
Message-ID: <20150811135907.GA22360@misc.lizard>
Date: Tue, 11 Aug 2015 06:57:09 -0700
From: sajolida <sajolida@pimienta.org>
To: sajolida@pimienta.org
Subject: TESTING ANACRON -- Low hanging fruit session: \Wednesday
\August \12
Message-ID: <20150811135709.GA22337@misc.lizard>
Date: Tue, 11 Aug 2015 06:55:37 -0700
From: sajolida <sajolida@pimienta.org>
To: sajolida@pimienta.org
Subject: TESTING ANACRON -- Low hanging fruit session: \Wednesday
\August \12
Message-ID: <20150811135537.GA22295@misc.lizard>

Which is probably me testing the thing before sending you the proper lines.

>

> $ sudo cat /var/spool/anacron/{lhf-session,monthly-meeting}
> 20150826
> 20150826
> 


>
>

> /var/log/syslog.6.gz:Aug 26 07:51:53 misc anacron[21773]: Job `monthly-meeting' started
> /var/log/syslog.6.gz:Aug 26 07:51:53 misc anacron[21773]: Job `monthly-meeting' terminated
> /var/log/syslog.6.gz:Aug 26 07:51:53 misc anacron[21773]: Job `lhf-session' started
> /var/log/syslog.6.gz:Aug 26 07:51:53 misc anacron[21773]: Job `lhf-session' terminated
> 


>
> … so I bet that it won’t run these jobs again before September 26, if I understand correctly how anacron is supposed to work.

So it’s not really what we want either… as we want these to be sent on
day 1.

> I’ve deleted /var/spool/anacron/{lhf-session,monthly-meeting}, and now I’m told:
>
>

> Sep  2 07:36:23 misc anacron[31256]: Will run job `lhf-session' in 15 min.
> Sep  2 07:36:23 misc anacron[31256]: Will run job `monthly-meeting' in 15 min.
> 


>
> So perhaps anacron is not what we need, as it lacks calendar time precision, and only cares about frequency. Sorry, I’m probably the one who suggested it initially.

That’s ok, we’re all learning…

> One solution would be to have the cronjob handles the scheduling/frequency details itself in a way that is robust against shutdown times (e.g. have a daily cronjob running, that checks some marker file’s mtime to see if the email have been sent yet, and if not starts the program that handles this and then touch’es the marker file). But it seems that systemd has exactly the functionality we need, that we could use in a declarative way — if curious, see the systemd.timer(5) manpage, in particular OnCalendar= (to specify when the unit shall be run) and Persistent= (that allows to “catch up on missed runs of the service when the machine was off”).

This time I’m not volunteering :)

I’m also surprised that we have to engineer this ourselves in the first
place. Sending reminders by email sounds like something generic and
useful in many cases, but I quickly search through the Debian archive
and couldn’t find any project doing that :(

#11 Updated by sajolida 2015-09-03 05:11:00

  • Status changed from In Progress to Rejected
  • Assignee deleted (sajolida)
  • QA Check deleted (Dev Needed)

I think I can reject this one then…