Can non-root user create/start services?

Tomasz CEDRO tomek at cedro.info
Tue May 18 21:28:30 UTC 2021


On Tue, May 18, 2021 at 10:52 PM K Lu  wrote:
> Right, I don't want to change to root for those tasks.
>
> That's why I'm curious, if the user can define and start "per-user"
> services. Not sure if I elaborate the use cases well :)
>
> Another option I can think of is using user cron jobs. Are there other options?

Cron is good to run periodic tasks - every hour, day, week, month.

You may want to put your local services into ~/.profile but that
requires login for them to be launched. They would not launch at boot.

You may set a system service to run as selected local user (i.e. vbox)
so you can access and probably control them as selected user (i.e.
manually kill, kill -HUP, start beyond system service).

You may put some services or script into /etc/rc.d/local that would
launch your local user services.

You may provide a web interface to see status and provide
enable/disable switch if you do not even want to login.

Either way you would probably have to create a control
(start/stop/status) scripts for your local services in your home
directory (i.e. $HOME/.local/etc/rc.d/). They could be started with
/etc/rc.d/local at boot or periodically controlled by cron - when not
running start would take place, when running no action taken, when
crashed they would start again.

Cron will however execute them no matter if you like it or not, so
either you edit your cron (crontab -e) or some additional
enable/disable flag for a service would have to be part of your local
configuration scripts.

You may take a look at /etc/rc.d/local as an example :-)

Good luck! :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info


More information about the freebsd-questions mailing list