Results 1 to 7 of 7

Thread: Kill process at startup

  1. #1
    Join Date
    Sep 2008
    Beans
    556
    Distro
    Ubuntu 12.04 Precise Pangolin

    Kill process at startup

    I am starting this thread as I did not receive any reply to my following post since long time.

    http://ubuntuforums.org/showthread.p...8#post12984948

    I am modifying my question as :

    • If at startup, I need to kill any process (which is running as root) when what should I write in a script and how to execute it at start up ?
    • I would also like to know how is kill process different from end process.

  2. #2
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Kill process at startup

    Can you give an example of the process(es) that you want to stop, or is this just a general question about how it is possible to do such things?

    As an example, I have openssh-server installed on my main box, but for security as I seldom need it running, I have it set to run only when I want it to with command
    Code:
    sudo service ssh start
    There are two ways in which I can achieve this; either stop it running in the first place by commenting out the line, as follows
    # start on filesystem or runlevel [2345]
    in /etc/init/ssh.conf which will stop it before it starts, or
    add the line
    service ssh stop
    to /etc/rc.local which will stop it after it starts.

    Better to stop it first in my opinion, and maybe the same will apply to you, but it will help to know what we are dealing with in detail, though if this is still about your running Quake, I can not really help, though my example may give you some possible clues.
    Last edited by ajgreeny; July 12th, 2014 at 12:17 PM.

  3. #3
    Join Date
    Sep 2008
    Beans
    556
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Kill process at startup

    Quote Originally Posted by ajgreeny View Post
    Can you give an example of the process(es) that you want to stop, or is this just a general question about how it is possible to do such things?

    As an example, I have openssh-server installed on my main box, but for security as I seldom need it running, I have it set to run only when I want it to with command
    Code:
    sudo service ssh start
    There are two ways in which I can achieve this; either stop it running in the first place by commenting out the line, as follows
    # start on filesystem or runlevel [2345]
    in /etc/init/ssh.conf which will stop it before it starts, or
    add the line
    service ssh stop
    to /etc/rc.local which will stop it after it starts.

    Better to stop it first in my opinion, and maybe the same will apply to you, but it will help to know what we are dealing with in detail, though if this is still about your running Quake, I can not really help, though my example may give you some possible clues.
    Yes it is about my Quake server which keeps running in the background.
    What command should be written in the terminal to kill any process (say the quake process) ?
    If the code has sudo then how can we make a script file do that work ?

  4. #4
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Kill process at startup

    Hi 3dmatrix.

    I can think of two ways:
    • Using the /etc/rc.local, as ajgreeny suggested, or
    • Using a @reboot entry in root's crontab.

    As for the proper code it would depend on how the quake service/daemon is launched.

    For instance, if it has upstart scripts:
    Code:
    service quake stop
    if it is just a process sent into the background:
    Code:
    killall quake
    Hope it helps. Let us know how it goes.
    Regards.

  5. #5
    Join Date
    Nov 2008
    Location
    S.H.I.E.L.D. 6-1-6
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Kill process at startup

    nvm
    Last edited by sandyd; July 13th, 2014 at 12:08 AM.
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  6. #6
    Join Date
    Sep 2008
    Beans
    556
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Kill process at startup

    sudo killall -v quake-engine-server
    [sudo] password for user:
    Killed quake-engine-server(1273) with signal 15

    The above code works in terminal but how can I make a script file and execute it.
    If possible without it asking for a password.

  7. #7
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Kill process at startup

    Add the line
    Code:
    killall -v quake-engine-server
    to the /etc/rc.local file just above the exit 0 line (as administrator) by using
    Code:
    sudo nano /etc/rc.local
    You will not need the sudo prefix as rc.local is already run as root at boot.
    I am not sure if the -v option in the killall command is needed, as that will show verbose output in terminal, and as the system is not running it in terminal it is probably superfluous.
    Last edited by ajgreeny; July 13th, 2014 at 10:50 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •