[systemd-devel] Adding a Timer section to .service files

Kai Krakow hurikhan77 at gmail.com
Sat Jul 9 14:14:16 UTC 2016


Am Fri, 8 Jul 2016 19:34:48 +0300
schrieb One Infinite Loop <6pozmo at gmail.com>:

> As I said before, I don't want to replace .service+.timer
> combination. I just think there are cases when .service file
> (containing, for example, ExecStart followed by many ExecStartPost)
> can have a [Crontab] section with .timer syntax. The two formats
> (service+timer and [Crontab] inside a service file) can coexist. It's
> just a suggestion.

It won't work that way. Because you need to enable timers. If the timer
is enabled, it will trigger the service by the same name (per default,
this can be configured). That service itself is not enabled - it just
sits there and will be started by the timer.

If you would enable said service, it would run at boot. Combining timer
and service into one file would thus just run the service at boot - I
don't think this is your intention.

If anything makes sense at all, then it would probably be to allow
ExecStart* within timer units - but that would only make sense for
Type=oneshot items - otherwise such a "timer" would fire once and stay
active.

Timer and service are split for good reason. It makes stuff so much
simpler from systemd view and much more flexible from admin view.

PS: Please do not top-post.

> On Fri, Jul 8, 2016 at 7:16 PM, Lennart Poettering
> <lennart at poettering.net> wrote:
> 
> > On Fri, 08.07.16 16:35, One Infinite Loop (6pozmo at gmail.com) wrote:
> >  
> > > A few usecases:
> > > 1) I want to delete specific files once a day  
> >
> > For this you probably should be using tmpfiles' "aging" logic, and
> > not define your own timer.
> >  
> > > 2)I want to free RAM using sync command and `echo 3 >
> > > /proc/sys/vm/drop_caches` every 15 seconds  
> >
> > Uh. Oh. I don't see why anyone would want to do this...
> >  
> > > 3)I want to make sure certain processes always run using a
> > > specific nice value like -15. I know control groups are invented
> > > but it's not the same thing.  
> >
> > Doing this with a service timer appears very strange to me. Simply
> > set "Nice=-15" in the unit file starting your service and the nice
> > level will be properly inherited by all processes of your services.
> >
> > But, in general, you could do all of the above with a combination of
> > .timer and .service file just fine already. These usecases are
> > perfectly covered, the only difference between what you are
> > proposing and what has been implemented is whether it's adding two
> > unit files per item instead of one, which I don't think is too
> > bad...
> >
> > Lennart


-- 
Regards,
Kai

Replies to list-only preferred.



More information about the systemd-devel mailing list