Difference between revisions of "Talk:Systemd/Timers"

From ArchWiki
Jump to navigation Jump to search
(→‎Counterproductive Suggestions: rm closed discussion)
(Started two discussions relating to crons RANDOM_DELAY feature)
Line 20: Line 20:
 
::* use a wrapper ("ExecStart=/usr/lib/mail_on_output /usr/bin/run-parts /etc/cron.daily/")
 
::* use a wrapper ("ExecStart=/usr/lib/mail_on_output /usr/bin/run-parts /etc/cron.daily/")
 
::--[[User:A-detiste|A-detiste]] ([[User talk:A-detiste|talk]]) 11:31, 4 November 2014 (UTC)
 
::--[[User:A-detiste|A-detiste]] ([[User talk:A-detiste|talk]]) 11:31, 4 November 2014 (UTC)
 +
 +
 +
=={{ic|RANDOM_DELAY}} cron alternative possible in systemd-229==
 +
Just a heads up. I've noticed that a new feature to rival [[cron|crons]] {{ic|RANDOM_DELAY}} has been added to the systemd master branch - [https://github.com/systemd/systemd/pull/1944 PR #1944]. At first it was called {{ic|RandomSec}} but it was quickley renamed to {{ic|RandomizedDelaySec}} - [https://github.com/systemd/systemd/pull/2040 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 {{ic|RANDOM_DELAY}}:
 +
# Under [[Systemd/Timers#Caveats|Caveats]] - it mentions that there is no built-in equivalent.
 +
# Under [[Systemd/Timers#Using_a_crontab|Using a crontab]] where it talks about alternatives (See [[#AUR_packages_that_provide_missing_cron_feature|AUR packages that provide missing cron feature]]).
 +
 +
[[User:Alux|Alux]] ([[User talk:Alux|talk]]) 13:15, 29 December 2015 (UTC)
 +
 +
 +
==AUR packages that provide missing cron feature==
 +
 +
Under [[Systemd/Timers#Using_a_crontab|Using a crontab]] it states that {{AUR|systemd-crontab-generator}} and {{AUR|systemd-cron}} provide an alternative to the missing {{ic|RANDOM_DELAY}} feature from [[cron]], both of the packages accomplish this using by simply translating the {{ic|RANDOM_DELAY}} (in minutes) environment variable to {{ic|AccuracySec}}(See the [https://github.com/systemd-cron/systemd-cron-next/blob/master/man/anacrontab.5.in systemd-crontab-generator] and [https://github.com/systemd-cron/systemd-cron/blob/master/src/man/anacrontab.5.in systemd-cron] man pages).
 +
 +
This goes against the advice in the note under [[Systemd/Timers#Caveats|Caveats]]:
 +
:{{note|The {{ic|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|RANDOM_DELAY cron alternative possible in systemd-229]]) the next version of systemd (229) will be getting a {{ic|RandomizedDelaySec}} feature so this could just be left until that changes. [[User:Alux|Alux]] ([[User talk:Alux|talk]]) 13:15, 29 December 2015 (UTC)

Revision as of 13:15, 29 December 2015

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)