Talk:Systemd/Timers

From ArchWiki
< Talk:Systemd
Revision as of 13:15, 29 December 2015 by Alux (talk | contribs) (Started two discussions relating to crons RANDOM_DELAY feature)
Jump to navigation Jump to search

Mailing output

Are there any built-in facilities for e-mailing the output of timed services? It doesn’t look as if there are. Maybe the wiki could outline a good practice for achieving that effect. A simple workaround would be having the service pipe output into sendmail, but maybe there’s a more elegant way (e.g., maintaining this would be cumbersome for many services). --Eigengrau (talk) 10:37, 14 May 2014 (UTC)

I just noticed that the Gentoo wiki has an example using a failure-email@.service which is started using OnFailure=. This seems like the right way to do it, but I don't fully understand their code. --Silverhammermba (talk) 15:14, 6 October 2014 (UTC)

Hi, I rewrote this for inclusion in systemd-cron mail_on_failure It nows checks for MAILTO=, like vixie-cron. --A-detiste (talk) 08:02, 31 October 2014 (UTC)

mail_on_failure's behaviour doesn't match vixie-cron's. Whereas mail_on_failure only sends mail when a job has failed, vixie-cron will send mail containing the job's output regardless of the job's exit status. (Same probably goes for the OnFailure= approach suggested by the Gentoo wiki, described above.) --Liujed (talk) 20:12, 2 November 2014 (UTC)
Indeed, the taste of users varies on this; OnFailure= was absolutely needed and easy to implement "mail on output" is not so straightforward. I've already discussed this elsewhere DebianBug and here systemd-devel .
Putting in a wrapper script between ExecStart= and the actual script is an added point of failure; using OnFailure is more robust. I even have this mailer run with an underprivilieged user
So to there remains work to get "mail on output", here is some options:
  • use some ExecStartPre= & ExecStartPost= magic that parse journalctl output with '--cursor' and save it somewhere
  • read $MAINPID in ExecStartPost= and do something with it
  • use a wrapper ("ExecStart=/usr/lib/mail_on_output /usr/bin/run-parts /etc/cron.daily/")
--A-detiste (talk) 11:31, 4 November 2014 (UTC)


RANDOM_DELAY cron alternative possible in systemd-229

Just a heads up. I've noticed that a new feature to rival crons RANDOM_DELAY has been added to the systemd master branch - PR #1944. At first it was called RandomSec but it was quickley renamed to RandomizedDelaySec - PR #2040. It looks as though some docs need cleaning up but it'll probably be in 229.

There are only two places in the article that reference crons RANDOM_DELAY:

  1. Under Caveats - it mentions that there is no built-in equivalent.
  2. Under Using a crontab where it talks about alternatives (See AUR packages that provide missing cron feature).

Alux (talk) 13:15, 29 December 2015 (UTC)


AUR packages that provide missing cron feature

Under Using a crontab it states that systemd-crontab-generatorAUR and systemd-cronAUR provide an alternative to the missing RANDOM_DELAY feature from cron, both of the packages accomplish this using by simply translating the RANDOM_DELAY (in minutes) environment variable to AccuracySec(See the systemd-crontab-generator and systemd-cron man pages).

This goes against the advice in the note under Caveats:

Note: The AccuracySec option is not useful for randomly staggering timers...

I'm not sure how this should be re-worded but it looks like (See RANDOM_DELAY cron alternative possible in systemd-229) the next version of systemd (229) will be getting a RandomizedDelaySec feature so this could just be left until that changes. Alux (talk) 13:15, 29 December 2015 (UTC)