You are not logged in.
Hi,
I am looking for a way to run a command as (regular) user at bootup. It's a "fire-and-forget" command and not a daemon (lxc-autostart, starts unprivileged containers). I wonder what the best approach would be to accomplish this and considered the following:
- write a minimal init.d script? (If yes: Is there a good template?)
- run it from rc.local (not what I actually want)
It would be great if the proposed solution would work for at least sysvinit and openrc without modifications.
Thank you in advance.
Last edited by kuleszdl (2019-03-16 14:35:00)
Offline
You can use init-d-script (man init-d-script) which encapsulates most of the complexity of dealing with writing an init-script. This is an almost unknown piece of the sysvinit package, that is not as widely used as it probably should be.
HTH
KatolaZ
Edit: actually, if what you need to run is not properly a daemon, rc.local might be the best solution.
Last edited by KatolaZ (2019-03-09 14:03:13)
Offline
It would be great if the proposed solution would work for at least sysvinit and openrc without modifications.
If you do write a script in init.d, making it LSB compliant (the ### BEGIN INIT INFO....### END INIT INFO stuff at the top) will ensure it runs properly in openrc.
Offline
Look for @reboot in man 5 crontab.
You can hook up auto-start jobs there without ever needing root's superpowers.
So it's somehow simpler than with sysvinit.
If you want to start a job logging to stdout or somewhen needing input (I use that for e.g. syncthing), start screen with @reboot and wire the desired job(s) into ~/.screenrc (similarly with tmux).
Last edited by yeti (2019-03-16 14:49:20)
*๐๐๐๐๐๐!*
Offline
Many thanks for all those hints. I didn't know about init-d-script and it looked promising, however, I didn't find a way to start the program as user with this mechanism.
Offline