Feature: Systemd timers - cockpit-project/cockpit GitHub Wiki
Create, inspect and modify systemd timers using Cockpit.
###Notes
- Interesting properties for commands: ExecStart, wants, Description
- Needs D-BUS methods to set timer property in systemd
- Interesting pages: systemd.timer, dbus reference, Modifying units.
- Notes on already merged parts: creating a timer with Cockpit (GSoC 2016)
Stories
Gregory runs intranet application server which monitors employees' productivity.
Wants to generate summaries: every hour, day, week, month, year. He does it by running custom commands. His commands work a lot with /tmp and he doesn't want to pollute it. It's also crucial that his commands are run even if his server is not running at specified time.
Jon wants to run application which is not really crucial for his work so he doesn't want it to slow down boot process. He wants to run existing unit one hour after system start.
Bruce is curious how system works under the hood so he wants to monitor when default system timers are run.
Alfred works as a system administrator at a small startup. They have a file server where everyone in the company stores all the code for their upcoming product, as well as presentations, important documents and other data for the project. At his last employer, they once lost an entire month of project data due to a hard drive failure. Alfred wants to avoid this happening again, so he wants to make a backup of the file servers data every night.
Phillip runs web service which involves uploading files to server.
He wants to run custom daily cleanups every day (delete files of non-premium users). It doesn't really matter if it's skipped one day. But he wants to monitor when it was run last time. His cleanups require running database to check if user has premium account.
###Workflows
Gregory:
- Opens services -> timers
- Clicks on create button
- Sets appropriate calendar time (
daily
,weekly
etc) - Specifies a "summaries" service to be run / creates one.
Jon:
- Opens services -> timers
- Clicks on create button
- Specifies application service to be run.
- Sets "1 hr" monotonic time from boot.
Bruce:
- Opens services -> timers for timer summary page.
Alfred:
- Opens services -> timers
- Clicks on create button
- Specifies backup service to be run /creates one.
- Sets a calendar time with
daily
.
Phillip:
- Opens services -> timers
- Clicks on create button
- Sets appropriate calendar time (
daily
,weekly
etc) - Specifies a "cleanup" service to be run / creates one.
- he can modify cleanup frequency later
Feature Request to systemd for having timer properties set via D-BUS
Currently timer properties like TimersMonotonic, TimersCalendar cannot be set via D-BUS.
Current method for setting timer involves creating a .timer
file with all the required properties mentioned in it.
Instead it would be better to have some properties like TimersCalendar
and TimersMonotonic
take values via D-BUS after connecting to that timer's D-BUS interface.
An example case for TimersCalendar Property :
The function SetCalendar()
takes 1st parameter as "OnCalendar"
and 2nd parameter like "daily"
, "weekly"
and like wise to set Timer's calendar property.
An example case for TimersMonotonic Property :
The function SetBootUsec()
takes an integer input (in usec) like for example 900000000
for 15mins.
The function SetUnitActiveUSec()
takes an integer input (in usec) like for example 900000000
for 15mins.
Having some timer properties (esp calendar, OnBootUsec and OnUnitActiveUsec) to be set via D-BUS through a method would help both developers and users.
Use Case: The current approach is to create .timer files with hard coded parameter values. It would be nice to have few methods in D-BUS that sets possibly calendar, monotonic timer (OnBootUsec, OnUnitActiveUSec) values.
Some other example use cases are :
- Alfred is a system administrator who makes a backup of the file servers data every night. He now wants backup only on a weekly basis. He could change/set timer from
daily
toweekly
by usingSetCalendar()
. - Jon wants to run application which is not really crucial for his work so he doesn't want it to slow down boot process. He wants to run existing unit one hour after system start.
SetBootUsec()
could help him set that time.
Note: This additional functionality was not found in the TODO list of systemd. https://github.com/systemd/systemd/blob/master/TODO
###Prior art Links to screenshots or documentation of other places where this problem has been solved.
###Mock up for timer development in Cockpit : https://trello.com/c/1B2lZViZ/74-timers-and-cron
Issues
- RFE: Allow creating persistent units via D-Bus https://github.com/systemd/systemd/issues/3234
- RFE: Support for scheduling end of the month days on timers https://github.com/systemd/systemd/issues/3861
- RFE: Crontab management https://github.com/cockpit-project/cockpit/issues/1297
Pull Requests
-
Add an option to create systemd timers. https://github.com/cockpit-project/cockpit/pull/4645
-
Display of next run and last run time of timers in timer page. https://github.com/cockpit-project/cockpit/pull/4503