[SOLVED] How do I start a daemon?

Forum Forums New users New Users and General Questions [SOLVED] How do I start a daemon?

Tagged: 

  • This topic has 11 replies, 7 voices, and was last updated Jan 6-8:47 pm by anticapitalista.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #48669
    Member
    amp

      Hi,

      I installed AntiX Core with a simple WM and am setting up my system.
      I’d like to know how can I start a daemon at boot that is not in the sysv-rc-conf list, for example gvfs.
      Also, how do I check if a daemon is enabled and running?

      Thanks.

      • This topic was modified 3 years, 6 months ago by amp.
      #48683
      Anonymous

        Change mpd to your service name..

        sudo service –status-all

        To start service

        sudo service mpd start

        To check status of service
        Check a service..

        sudo service mpd status

        Start a service..

        sudo service mpd start

        To stop service..

        sudo service mpd stop

        To relaod service (i.e. stop + start ) do

        sudo service mpd reload

        #48684
        Anonymous

          “gvfs” is not the exact name of an executable, right?

          To have an arbitrarily chosen (by you) executable launched automatically, prior to start of the desktop session… you would create an init script for it, mark the script executable and place it in /etc/init.d/ then you would use the tool (command) update-rc.d to register the script into your system’s init configuration.

          #48685
          Anonymous

            A SysV (aka SystemV) init walkthrough

            During boot, immediately following Linux kernel initialization, the init script executes /sbin/init

            === In the “live boot” scenario, an interim init (extracted from within the initrd)
            === is executed, and it performs a plethora of operations prior to calling
            === the switch_root command and handing off to /sbin/init

            /sbin/init reads /etc/initscript and consults /etc/inittab
            (which governs a series of scripts required to complete the initialization process)
            ^—v
            Next, /sbin/init (according to entries in /etc/inittab)
            will exec /etc/xxxxxx passing to it the requested initial runlevel (as specified in /etc/inittab)

            ===
            === above, I’m omitting some details in this draft
            ===

            The numbering convention for runlevels, across linux distributions, typically includes
            0 = halt
            1 = single-user mode (only runs /etc/rc.d/rc.sysinit; does not run /etc/rc.d/rc)
            6 = reboot
            and runlevels 2-3-4-5 are configured to achieve various forms of multi-user mode

            Theoretically, you could declare n configure additional runlevels 7 thru 9. If you configured
            a “runlevel 7”, its operation would be no higher//better//later than the existing numbered runlevels,
            (mentioned just for sake of completeness: Doing this would be accomplished by editing /etc/inittab )

            SysVinit goes directly to the runlevel specified in /etc/inittab; It does not consult
            the scripts in the other levels. However, at each boot, we can provide a bootline
            argument to override the configured default target runlevel.

            While a system is running, admin can command a switchover from one runlevel to another,
            via the init (aka ‘telinit’) command. When switching runlevels, the init system assesses the difference
            between the current and target runlevel. Any processes listed for the current level but not in the target
            runlevel are killed using the kill scripts, then any listed for the target runlevel but not in the
            current are executed. Items that exist in both run levels are left undisturbed.

            ===
            ===
            ===

            on antiX (and other OSes using SysV init) all startup scripts for any process which will be started
            when entering one (or several) of the runlevels, are stored in // read from the directory /etc/init.d/
            .
            The initscripts are processed in numerical order, according to your assigned script filenames.
            .
            After placing a new script into /etc/init.d/, you can use the tool (command) ____ update-rc.d _____
            to generate symlinks ~~ one symlink will be added into each of the numbered /etc/rc[0-6]/ directories.
            If the new script is to be stopped for a given runlevel, update-rc.d will preface the name of its symlink
            with a K (kill); it the new script is intended to be started for that runlevel, an S (start) prefix
            will be applied.
            .
            Learn by example: inspect the content of the various existing /etc/init.d/ “init scripts” and note
            the convention(s) used in their declaratory header lines.
            .
            Various tutorials are available online. For example: http://wiki.linuxquestions.org/wiki/Creating_startup_scripts

            relevant manpages:
            man update-rc.d
            man runlevel
            man init
            man initscript
            man inittab

            #48686
            Anonymous

              Glancing at the above, I think it is probably important to also note that
              a process called via an initscript will not necessarily be a “daemon”.
              (Many of ’em, run in order to perform prep, or housekeeping upon entering a runlevel then they immediately exit.)

              Someone else can please post a followup to explain
              /etc/rc.local

              #48689
              Anonymous

                how do I check if a daemon is enabled and running?

                sudo ps -aux | grep <name of process>
                or
                “sudo htop” and lookaround

                To check which init scripts are enabled for any/every runlevel:
                man insserv
                sudo insserv -s
                (it will probably be desirable to | pipe the insserv output through grep filter it)

                #48699
                Anonymous

                  Thanks skidoo some useful info there added to my antiX help file. The only time I have used gvfs so my phone would connect with thunar. Which I don’t use anymore as spacefm is my choice of gui file managers and as for the phone I just run the antiX phone connect script works a treat.

                  #48715
                  Member
                  seaken64

                    Thanks skidoo, that was very informative and is helping me understand the init process. Thanks again for sharing.

                    seaken64

                    #48749
                    Member
                    amp

                      Thanks a lot for the complete and articulate answers.
                      Happy 2021!!!

                      #48758
                      Moderator
                      Brian Masinick

                        I made this thread stick at the top, at least for a while.

                        The posts that skidoo provided, very concisely, describe a significant amount of system administration and system understanding.

                        If you can understand it, you are in great shape!

                        If not, but you want to learn, try to either get some really good books if you learn that way or start making effective use of the Internet to better understand how software works.

                        In any case it’ll be challenging to find a better description of the init system, run levels, etc. Great information and that’s why this thread is marked sticky for a while.

                        If we add to any of our system learning and set-up sections it would be great to either include or cite some of the key points in this thread.

                        Thanks again skidoo!

                        --
                        Brian Masinick

                        #49213
                        Member
                        azpicacho

                          Hello,

                          I use AntiX 19.3 with runit an fluxbox and read with interest this thread.

                          Koo wrote how to start/stop a daemon with sysVinit, I guess.

                          Is it the same procedure with runit init system ?

                          thx

                          #49225
                          Forum Admin
                          anticapitalista

                            Hello,

                            I use AntiX 19.3 with runit an fluxbox and read with interest this thread.

                            Koo wrote how to start/stop a daemon with sysVinit, I guess.

                            Is it the same procedure with runit init system ?

                            thx

                            On Debian and thus antiX, (at the moment) yes.
                            Other distros running runit (eg Void, Artix) do it differently, but their way will not work on Debian or antiX + runit.

                            Philosophers have interpreted the world in many ways; the point is to change it.

                            antiX with runit - leaner and meaner.

                          Viewing 12 posts - 1 through 12 (of 12 total)
                          • You must be logged in to reply to this topic.