1

I have a VM running under Fedora OS. That VM has four users lets say(A, B, C, D). That VM has one process running under each user. So when that VM is rebooted, what should I do so that those process auto starts under respective user.

Provided that

a is the custom command to start a process under A user

b is the custom command to start a process under B user

c is the custom command to start a process under C user

d is the custom command to start a process under D user

a,b,c,d are the commands that are not available to root user. They are only available to respective users.

Thanks

Gagan
  • 111
  • 3

2 Answers2

2

Create a separate Systemd init script for the processes. For process A create the file /etc/systemd/system/A.service and add something like this to it:

[Unit]
Description=Process A
After=network.target

[Service]
User=userA
Type=forking
ExecStart=/some/command/to/run --arg1 --arg2
Restart=on-failure
StartLimitInterval=5min
StartLimitBurst=4

[Install]
WantedBy=multi-user.target

Customize this as you like (Restart, StartLimitInterval, StartLimitBurst, etc...)

Then enable it with

systemctl enable A.service

and start

systemctl start A.service
Stone
  • 6,941
  • 1
  • 19
  • 33
1

Can you use the /etc/crontab and the @reboot time. The format of the /etc/crontab takes a username after the time specification and the process is run as that user.

@reboot A /path/to/a
@reboot B /path/tob

and so on.

user9517
  • 114,104
  • 20
  • 206
  • 289