• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Linux init.d scripts

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Linux init.d scripts

    In order to stop and start applications automatically on Debian I created a script based on the skeleton in /etc/init.d and then ran the update-rc.d command on it:

    update-rc.d test_server1 start 99 3 . stop 01 0 6

    This created the relevant links in /etc/rc3.d to start it and in /etc/rc0.d and rc6.d to stop it. The problem seems to be that at system boot time it doesn't seem to run the script but at system shutdown it does. You can run the script manually but need to provide a parameter (start/stop/restart/status) so I know it is working and as can be seen, the shutdown is fine. I'm just wondering as to why the start is not being picked up.

    The only differences between the stop and start is that start uses the start-stop-daemon, i.e.


    start-stop-daemon --start --pidfile $PIDFILE --startas $DAEMONSTA $NAME --test > /dev/null \
    || return 1
    start-stop-daemon --start --pidfile $PIDFILE --startas $DAEMONSTA $NAME -- \
    || return 2


    whereas stopping it uses commands sent to the server as start-stop-daemon justs gets the pid and then kills the process but I want it to stop cleanly, i.e.

    $DAEMONSTO $NAME -user adminuser -password password

    The restart just calls the above 2 steps and works fine. Just wondering if I missed something somewhere...TIA.
    Brexit is having a wee in the middle of the room at a house party because nobody is talking to you, and then complaining about the smell.

    #2
    Is the chkconfig line in the top of the script. I think that needs to be there it won't get run.
    McCoy: "Medical men are trained in logic."
    Spock: "Trained? Judging from you, I would have guessed it was trial and error."

    Comment


      #3
      Originally posted by lilelvis2000 View Post
      Is the chkconfig line in the top of the script. I think that needs to be there it won't get run.
      No chkconfig in Debian I'm afraid.
      Brexit is having a wee in the middle of the room at a house party because nobody is talking to you, and then complaining about the smell.

      Comment


        #4
        sorry -- I run two Ubuntu server and one CentOS - you'd think I'd know that.

        have you tried just:

        update-rc.d test_server1 start 99 3 4 5 . stop 99 0 1 6 .
        McCoy: "Medical men are trained in logic."
        Spock: "Trained? Judging from you, I would have guessed it was trial and error."

        Comment


          #5
          Sorry to state the bleedin obvious but did you make this script runnable?

          chmod 755 /etc/init.d/blah

          type of thing?
          Knock first as I might be balancing my chakras.

          Comment


            #6
            Originally posted by suityou01 View Post
            Sorry to state the bleedin obvious but did you make this script runnable?

            chmod 755 /etc/init.d/blah

            type of thing?
            Did you get this sorted? Let us know.
            Knock first as I might be balancing my chakras.

            Comment


              #7
              Originally posted by suityou01 View Post
              Did you get this sorted? Let us know.
              End of last week as a matter of fact, need to fully test it but looks like its working. I just did:

              # update-rc.d test-server1 defaults 01 99

              It would be nice to see the messages in the logs but the server starts and stops. Cheers.
              Brexit is having a wee in the middle of the room at a house party because nobody is talking to you, and then complaining about the smell.

              Comment

              Working...
              X