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...
It always a Better to run the system as non-root user. The account created during installation is an administrator account. In Ubuntu, root account has no password and as a consequence, you can not login as the root user. There are ways to circumvent this, but this is the default setting.
Run Systemd Service as standard Logged in userCreate a systemd service unit file under the directory. Reload systemd. Confirm the service is available. $ systemctl --user list-unit-files syncthing.
When it comes to working with Linux, there are two ways to run administrative applications. You can either change over to the super user, also known as the root account, using the “su” command, or you can use the “sudo” command.
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!!!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With