5

I want to execute my scripts at boot time through systemd (OS is Fedora Core 16) from some non-root user (e.g. michael).

I don't need root privileges - I only want to run at boot time and at shutdown time some of my units in systemd. And I don't want to turn on a root user for this. I only want to use power of systemd syntax of units for starting and watching for my process (of course without root access). Is it possible?

I didn't find any help in the documentation. I only found in systemd(1) -> DIRECTORIES -> "User unit directories":

$ pkg-config systemd --variable=systemduserunitdir
/usr/lib/systemd/user

But the /usr/lib/systemd/user is:

drwxr-xr-x. 2 root root

I cannot imagine how I can use this directory as a non-root user...

David Cain
  • 16,484
  • 14
  • 65
  • 75
Perlover
  • 131
  • 1
  • 7
  • As i understood the "systemduserunitdir" directory has a units for user sessions (ssh / X sessions?). If yes it variable will not help to me :( I want to start/stop/enable/disable services/daemons in systemd without user sessions (at boot time) but as non root user. And i don't want to obtain root access for installing my programs (daemons) if its don't need in root privileges... – Perlover Apr 18 '12 at 09:31
  • Have you tried asking this on superuser.com, a related website focusing on computer questions more than programming questions? – inquiryqueue Jun 26 '12 at 18:48

2 Answers2

3

This Arch Linux document may help.

systemd offers users the ability to run an instance of systemd to manage their session and services. This allows users to start, stop, enable, and disable units found within certain directories when systemd is run by the user. This is convenient for daemons and other services that are commonly run as a user other than root or a special user, such as mpd.

They suggest starting a system --user instance via xinit, but I suppose you want to start the user services regardless of whether the user is logged in.

I would normally do that by adding an @reboot line to my crontab.

From Wikipedia:

@reboot can be useful if there is a need to start up a server or daemon under a particular user, and the user does not have access to configure init to start the program.

Maybe you can start systemd --user via @reboot!!!

Perception
  • 79,279
  • 19
  • 185
  • 195
richardw
  • 728
  • 5
  • 9
2

Create a user systemd unit file for 'michael'.

Here's the magic to ensure users systemd process will kick off at boot instead of at login:

loginctl enable-linger michael

Full details

Guy Gangemi
  • 1,533
  • 1
  • 13
  • 25