0

I want to run a process with a specific user.

On RHEL 7, I am able to this with:

source /etc/rc.d/init.d/functions
daemon --user=myuser $JAVA_HOME/bin/java -cp $appClassPath $MAIN_CLASS

How can I achieve the same behavior on SLES12? The /etc/rc.d/init.d/functions is not available on SLES12 out of the box.

  • 1
    https://unix.stackexchange.com/questions/363098/running-a-systemd-service-as-a-user-other-than-root – ron Nov 25 '19 at 21:03
  • 1
    also search on`systemd user service`. might be what you want. – ron Nov 25 '19 at 21:45

1 Answers1

0

SUSE wants Your to use LSB start_daemon. (https://en.opensuse.org/openSUSE:Packaging_init_scripts).
But I'm not certain whether it will be continued in systemd times or is about to be phases out.
Of course recommended way in systemd systems is to create a systemd unit...

Otherwise use the default tools like runuser or su or even sudo which has the convenience that You can call it as any user with permissions to run that command line.
Background and detach Your program within these wrappers (or exec it). Possibly with help of nohup.
That is more standard conforming and not coupled to a deprecated init-system infrastructure.

user301446
  • 586
  • 2
  • 6