[opensuse] how does a user create systemd timers?
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? -- Per Jessen, Zürich (13.1°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
15.09.2017 20:52, Per Jessen пишет:
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?
Put them in one of user unit directories (i.e. ~/.config/systemd/user or ~/.local/share/systemd/user) and run "systemctl --user daemon-reload). The main difference is that (pam_)systemd starts per-user systemd instance on first logon and stops on the last logoff. You need to explicitly enable lingering for user to start user systemd instance on boot time so your timer can run when user is not logged in. This was discussed (and requested) but so far there is no good solution (doing it for each user is not feasible). OTOH it is similar to opt-in cron mode where users must be explicitly allowed to use it. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 09/15/2017 11:06 AM, Andrei Borzenkov wrote:
You need to explicitly enable lingering for user
Hasn't just about every distro turned on linger by default, especially for user 1000? Everything I've installed lately has linger turned on. -- After all is said and done, more is said than done. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
John Andersen wrote:
On 09/15/2017 11:06 AM, Andrei Borzenkov wrote:
You need to explicitly enable lingering for user
Hasn't just about every distro turned on linger by default, especially for user 1000?
Everything I've installed lately has linger turned on.
Looking at my Leap423 test system, linger isn't on for my userid. loginctl show-user per UID=1000 GID=100 Name=per Timestamp=Fri 2017-09-15 19:52:43 CEST TimestampMonotonic=3313865425738 RuntimePath=/run/user/1000 Service=user@1000.service Slice=user-1000.slice Display=3698 State=active Sessions=3698 IdleHint=no IdleSinceHint=0 IdleSinceHintMonotonic=0 Linger=no -- Per Jessen, Zürich (8.8°C) http://www.hostsuisse.com/ - dedicated server rental in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
16.09.2017 08:48, Per Jessen пишет:
John Andersen wrote:
On 09/15/2017 11:06 AM, Andrei Borzenkov wrote:
You need to explicitly enable lingering for user
Hasn't just about every distro turned on linger by default, especially for user 1000?
Everything I've installed lately has linger turned on.
Looking at my Leap423 test system, linger isn't on for my userid.
I was sure enabling lingering was privileged action, but apparently it is now allowed by default for a plain user to do it. Seems to went in systemd v230. This makes the whole more like documentation issue than fundamental design problem. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On September 24, 2017 12:02:47 AM PDT, Andrei Borzenkov <arvidjaar@gmail.com> wrote:
16.09.2017 08:48, Per Jessen пишет:
John Andersen wrote:
On 09/15/2017 11:06 AM, Andrei Borzenkov wrote:
You need to explicitly enable lingering for user
Hasn't just about every distro turned on linger by default, especially for user 1000?
Everything I've installed lately has linger turned on.
Looking at my Leap423 test system, linger isn't on for my userid.
I was sure enabling lingering was privileged action, but apparently it is now allowed by default for a plain user to do it. Seems to went in systemd v230.
This makes the whole more like documentation issue than fundamental design problem.
It mostly means Pottering lost the argument an the system went back to the way it was for decades. I think it still defaults to no longer for non wheel users, but allows changes. -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Andrei Borzenkov wrote:
15.09.2017 20:52, Per Jessen пишет:
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?
Put them in one of user unit directories (i.e. ~/.config/systemd/user or ~/.local/share/systemd/user) and run "systemctl --user daemon-reload).
Thanks. On Leap423, ~/.local/share/systemd/user is symlinked to ~/.config/systemd/user
The main difference is that (pam_)systemd starts per-user systemd instance on first logon and stops on the last logoff. You need to explicitly enable lingering for user to start user systemd instance on boot time so your timer can run when user is not logged in. This was discussed (and requested) but so far there is no good solution (doing it for each user is not feasible).
Okay. I have some 7-8 jobs in my crontab, but I am almost certainly the only user in our office that uses it. No need to think about migrating. -- Per Jessen, Zürich (8.9°C) http://www.cloudsuisse.com/ - your owncloud, hosted in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
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: https://wiki.archlinux.org/index.php/Systemd/Timers -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
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: https://wiki.archlinux.org/index.php/Systemd/Timers
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. -- Per Jessen, Zürich (19.4°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
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: https://wiki.archlinux.org/index.php/Systemd/Timers
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 user. https://wiki.archlinux.org/index.php/Systemd/User -- _____________________________________ ---This space for rent--- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, Oct 3, 2017 at 11:37 AM, John Andersen <jsamyth@gmail.com> wrote:
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 user.
Really? Please show where you have found this statement.
This page says: "The systemd user instance is started after the first login of a user and killed after the last session of the user is closed". Where do you see anything about "timers (or other units)"? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
John Andersen wrote:
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.
Yes, so did I eventually. I copied the logrotate timer, but overlooked the 'AccuracySec=12h' setting.
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 user.
Well, that bit is definitely not correct. I've got a test timer, it certainly only runs when I'm logged in. (I have yet to figure out how to enable lingering). -- Per Jessen, Zürich (13.5°C) http://www.dns24.ch/ - free dynamic DNS, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/03/2017 02:12 AM, Per Jessen wrote:
Well, that bit is definitely not correct. I've got a test timer, it certainly only runs when I'm logged in. (I have yet to figure out how to enable lingering).
man loginctl -- After all is said and done, more is said than done. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/03/2017 02:12 AM, Per Jessen wrote:
Well, that bit is definitely not correct. I've got a test timer, it certainly only runs when I'm logged in. (I have yet to figure out how to enable lingering).
Also, I forgot to mention you can check with: loginctl show-user 1000 to verify that linger gets turned on and sticks. -- After all is said and done, more is said than done. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (4)
-
Andrei Borzenkov
-
David C. Rankin
-
John Andersen
-
Per Jessen