Bug 902110 - RFE: support restarting unit on calendertime
Summary: RFE: support restarting unit on calendertime
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: systemd-RFE
TreeView+ depends on / blocked
 
Reported: 2013-01-20 22:25 UTC by Jóhann B. Guðmundsson
Modified: 2013-07-26 01:29 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-07-26 01:29:49 UTC
Type: Bug


Attachments (Terms of Use)

Description Jóhann B. Guðmundsson 2013-01-20 22:25:36 UTC
Description of problem:

I'm analysing those 38 out of 99 cron jobs that we ship, that are potentially worth migrating to native systemd timers unit  when I noticed that one of those cron job is restarting the service on a specific date and given that we have had to do the same @dayjob there are definitely use cases to support this thus I propose we implement something like 

Restart=On-Date
OnCalendar=

which would support having the service restarted on a specific date/time

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Harald Hoyer 2013-04-10 10:58:41 UTC
Can be solved by:

# cat ServiceRestart@sshd.timer
[Unit]
Description=Restart sshd service every minute

[Timer]
OnCalendar=*-*-* *:*:00

# cat ServiceRestart@.service 
[Unit]
Description=Restart service %I

[Service]
ExecStart=/usr/bin/systemctl restart %I.service

Comment 2 Jóhann B. Guðmundsson 2013-04-10 11:26:53 UTC
You could also with a script and execute that from cron like having to create two units. 

Sorry to say but from my pov view the whole integration of "timer" is not so good both from usability perspective and consistency with units types for this to be useful and consistent for administrators we ought to support simply adding an switch to Restart= followed supporting defining OnCalender= in [service] sections by doing so we a) support what this request is for b) properly can intergrade timer jobs in services without having to result to create a specific timer unit and start "Binding" them and what not to other service

Comment 3 Lennart Poettering 2013-07-26 01:29:49 UTC
I agree with Harald, what he suggests in #1 is a solution that is "good enough".

We should be very careful with making things like this "too easy", since they actually might cause races where the admin edits a configuration file and the cronjob then restarts the service in the background while the configuration file is only half-written.

it's fine if admins hack things up to make a service restart in fixed intervals, but I am very conservative on making something like this a primary functionality of systemd.

Sorry, I am not convinced that adding this would be a good idea, hence closing.


Note You need to log in before you can comment on or make changes to this bug.