How can I add commands to system init (SysV)?

Message
Author
davejones
Posts: 10
Joined: Sun Jan 07, 2018 7:07 am

How can I add commands to system init (SysV)?

#1 Post by davejones »

- OS: MX Linux 18
- Window Manager: i3 version 4.13

I wish for the Emacs server (emacsclient) and Tmux to be started at boot. Is it possible to add the service to MX Linux's init system (SysV)?

I tried adding it those to my i3wm init but it doesn't work.

This is the command I use to start emacsclient:

Code: Select all

exec --no-startup-id "emacsclient --socket-name=gui-emacs --no-wait --create-frame"
And this is the script I use to start my tmux sessions.

Both commands work fine in the command-line.
Last edited by davejones on Wed Jun 26, 2019 2:07 am, edited 1 time in total.

User avatar
Jerry3904
Administrator
Posts: 23625
Joined: Wed Jul 19, 2006 6:13 am

Re: How can I add commands to system init (SysV)?

#2 Post by Jerry3904 »

You can add commands using MX Boot options
Production: MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: MX-25 Fluxbox, ThinkPad X1 Carbon gen 9 with i7
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
Davo
Posts: 29
Joined: Sun Jul 30, 2006 12:38 pm

Re: How can I add commands to system init (SysV)?

#3 Post by Davo »

Put it somewhere in /etc/init.d/directory. Make it owned by root (chown) and executable (chmod 755 stuff) and that it is S in the right runlevel should just work

User avatar
yoshi
Posts: 74
Joined: Mon May 13, 2019 10:16 am

Re: How can I add commands to system init (SysV)?

#4 Post by yoshi »

hi
first check if in /etc/init.d if a script was created during installation of your apps.

(If not you need to write a script to tell what need to happen -
see https://www.thegeekstuff.com/2012/03/lsbinit-script )


then start

Code: Select all

sudo sysv-rc-conf
and add the script to the runlevels in which it should be started.
default runlevel seems to be 5 (use command $>

Code: Select all

runlevel
to check or cat /etc/inittab | grep initdefault )

some general understanding of sysV is given here:
https://www.digitalocean.com/community/ ... -reference

way easier would it be to start your apps on start of the XFCE session.
For that you just start

Code: Select all

xfce4-session-settings
-> goto Autostart Applications and there you add your commands
Life is too beautiful to observe it through windows. :penguin:

User avatar
UncleBaldie
Posts: 2
Joined: Fri Aug 05, 2016 5:53 pm

Re: How can I add commands to system init (SysV)?

#5 Post by UncleBaldie »

exec --no-startup-id "emacsclient --socket-name=gui-emacs --no-wait --create-frame

Maybe I'm missing something here, or maybe I'm a bit thick, but shouldn't there be closing quotes ?

Just saying....

Phil

User avatar
yoshi
Posts: 74
Joined: Mon May 13, 2019 10:16 am

Re: How can I add commands to system init (SysV)?

#6 Post by yoshi »

I completely forgot the easiest way.
What I do on single user systems (if only one user is using the machine eg. on my laptop and Raspberry Pi Embedded Systems) is to put a script in
my home folder and call it from /etc/rc.local
Alternatively you can also put your commands directly into /etc/rc.local
It will automatically get called on startup

example:

Code: Select all

more /etc/rc.local 

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#

/home/your_/_path/your_script.sh &         #script in home folder needs to be exectutable
#or
your_command1 &
your command2 &

exit 0
another way is to use cron: https://www.a2hosting.com/kb/developer- ... ver-reboot
Life is too beautiful to observe it through windows. :penguin:

davejones
Posts: 10
Joined: Sun Jan 07, 2018 7:07 am

Re: How can I add commands to system init (SysV)?

#7 Post by davejones »

UncleBaldie wrote: Thu Jun 20, 2019 6:44 pm exec --no-startup-id "emacsclient --socket-name=gui-emacs --no-wait --create-frame

Maybe I'm missing something here, or maybe I'm a bit thick, but shouldn't there be closing quotes ?

Just saying....

Phil
Yes, it should, and there are closing quotes in my actual config. Sorry, I didn't paste it properly. This is now fixed.

davejones
Posts: 10
Joined: Sun Jan 07, 2018 7:07 am

Re: How can I add commands to system init (SysV)?

#8 Post by davejones »

Jerry3904 wrote: Thu Jun 20, 2019 3:31 pm You can add commands using MX Boot options
Are you referring to this screen?. Cause I don't any a field for inserting commands, nor any such indication in the help file.

User avatar
Jerry3904
Administrator
Posts: 23625
Joined: Wed Jul 19, 2006 6:13 am

Re: How can I add commands to system init (SysV)?

#9 Post by Jerry3904 »

"Kernel commands" is not what you want?
Production: MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: MX-25 Fluxbox, ThinkPad X1 Carbon gen 9 with i7
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

Post Reply

Return to “Software / Configuration”