Question

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

Was it helpful?

Solution

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

OTHER TIPS

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!!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top