Mailinglist Archive: opensuse (783 mails)

< Previous Next >
Re: [opensuse] how does a user create systemd timers?
On 09/24/2017 6:55 AM, Per Jessen wrote:
David C. Rankin wrote:

On 09/15/2017 12:52 PM, Per Jessen wrote:
I wrote:
What I find less easy is to tell when cronjob is going to fire

a) at 30 minutes past every 3rd hour.
b) at 2,17,32,47 minutes past every hour
c) 10 past midnight on the 1st of the month.
d) Sunday at 04:00.

Just as I sent this off, somehow it reminded me of Andrei mentioning
/var/spool/cron/tabs -

just being curious - how does a user create systemd timers for
himself? Is there some really simple answer to this that I have
completely missed?

Have a look at:

Umm, that page doesn't actually explain $SUBJ :-) - how does a _user_
create systemd timers. Anyway, it's a little more complicated
than "crontab -e":

a) create ~/.local/share/systemd/user/mytimer.timer
b) create ~/.local/share/systemd/user/mytimer.service

systemctl --user daemon-reload
systemctl --user enable mytimer.timer
systemctl --user start mytimer.timer

(why doesn't systemctl default to --user when uid>=1000 ?)

And then enable lingering to have the cronjob run also when the user
isn't logged in.

I played with it a bit, but ISTR I had trouble getting the timer to fire
at the right time.

Since the thread is old at this time, I won't bore you with the details,
but I simply took something like the the fstrim timer, and cloned that,
and adjusted the time to my liking.

I've found the starting of tasks to be rather precise as the timer
options are quite varied and capable with OnCaleendar options and stuff.
I've started daily jobs and had them fire within a second of when I exptected
them to.

For a couple of these tasks I did want to start it with my own timer rather
than as root,
because there were going to be several people with their own timer+service
similar to
your example above.

The systemd/user arch wiki page explains starting your user instances
of systemd be done automatically when you log in the first time, and
it will remain as long as there exists timers (or other units) for that

---This space for rent---

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >