Announcement

Collapse
No announcement yet.

Restart KDM from a script

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Restart KDM from a script

    Hi. I'm trying to write a script that does a few things and then restarts the X server. I've tried (as root):

    Code:
    /etc/init.d/kdm restart
    And:

    Code:
    /etc/init.d/kdm stop
    /etc/init.d/kdm start
    And even:

    Code:
    /etc/init.d/kdm stop
    sleep 5
    /etc/init.d/kdm start
    But each time, KDM does not start back up after stopping. If I log into the console and issue the sudo /etc/init.d/kdm start command from there, it comes up fine, though. Does anyone know why this won't work or if there's a better way? I had a similar problem on openSUSE a while ago and was able to solve it by introducing a pause before starting (i.e. the third snippet above). But the same trick does not work for Kubuntu.

    #2
    Re: Restart KDM from a script

    Without thinking too hard about why it is behaving like that, why not try
    /etc/init.d/kdm restart
    or
    invoke-rc.d kdm restart

    Comment


      #3
      Re: Restart KDM from a script

      Originally posted by mando_hacker
      Without thinking too hard about why it is behaving like that, why not try
      /etc/init.d/kdm restart
      or
      invoke-rc.d kdm restart
      I did try the first one. (See original post.) I get the same result from the second one.

      Comment


        #4
        Re: Restart KDM from a script

        This may be elementary, but does your scripts have the
        #! /bin/bash
        as the first line, and did you set their executable permissions on?
        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
        – John F. Kennedy, February 26, 1962.

        Comment


          #5
          Re: Restart KDM from a script

          Originally posted by GreyGeek
          This may be elementary, but does your scripts have the
          #! /bin/bash
          as the first line, and did you set their executable permissions on?
          Yes, the script starts fine. And as I said, KDM does shut down. It just doesn't come back up.

          Comment


            #6
            Re: Restart KDM from a script

            So, root is the owner of the script?
            And, you are calling it (or have the code in) from /etc/bash.bashrc or /etc/profile or /etc/rc.local?

            Check with man sudo_root for reasons why some commands don't work within the sudo command.
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #7
              Re: Restart KDM from a script

              I think you are starting it from a process that is a child of KDM. As soon as youkill KDM you have no process left to restart KDM. Try it from a VT and it will work.

              Comment


                #8
                Re: Restart KDM from a script

                Originally posted by mando_hacker
                I think you are starting it from a process that is a child of KDM. As soon as youkill KDM you have no process left to restart KDM. Try it from a VT and it will work.
                Bingo! You are right. Worked fine from a VT. Now I need to figure out how to run the script so it's not a child process of KDM, even though I need to invoke it from within KDE. Is there a trick?

                Comment


                  #9
                  Re: Restart KDM from a script

                  Nothing jumps out at me. I would need to know more about what you are trying to accomplish.

                  Comment


                    #10
                    [SOLVED] Restart KDM from a script

                    Actually, I think I've got it. It's not a child process of KDM, but rather a child of the Konsole instance that I was using to test it. If I run the script from KRunner, it works as intended. Thanks for your help.

                    Comment


                      #11
                      Re: [SOLVED] Restart KDM from a script

                      Originally posted by Rob_H
                      Actually, I think I've got it. It's not a child process of KDM, but rather a child of the Konsole instance that I was using to test it. If I run the script from KRunner, it works as intended. Thanks for your help.
                      More precisely, it was a child of the bash instance.

                      Comment


                        #12
                        Re: Restart KDM from a script

                        Yup. So then you could create a menu button for it also and be able to reliably restart KDM, which the system will not do right now.

                        Comment

                        Working...
                        X