Bug 902110

Summary: RFE: support restarting unit on calendertime
Product: [Fedora] Fedora Reporter: Jóhann B. Guðmundsson <johannbg>
Component: systemdAssignee: systemd-maint
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: harald, johannbg, lnykryn, metherid, msekleta, notting, plautrba, systemd-maint, vpavlin
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-26 01:29:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 784611    

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
[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.