Find the answer to your Linux question:
Results 1 to 6 of 6
I need a button that destorys all the VNC sessions on the box. And thus logs the Entire system off nicely.. Is there a way to do this nicely? Like: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,429

    Kill Process by name?


    I need a button that destorys all the VNC sessions on the box.
    And thus logs the Entire system off nicely..
    Is there a way to do this nicely?
    Like:
    Code:
    ps aux
    or
    Code:
    ps -C vnc
    and then add some Kill Function behind it?

    Already thanks a lot =)

    Cheers,
    Robin
    New Users, please read this..
    Google first, then ask..

  2. #2
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,133
    You can just use the killall command. This will look up all PIDs by app name and kill them off.

  3. #3
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,429
    heh thanks but it aint that easy
    Since there are some Deamons running that NEVER may stop..
    So, killall aint a option..

    Cheers,
    Robin
    New Users, please read this..
    Google first, then ask..

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,049
    My 'stop' script still serves a good purpose. It searches for patterns, not just names of processes. So you can kill by user, or any other pattern in the output of <ps aux>. Note! That it's buggy as hell and that it has caused discussing wetter or not it should work in theoretical terms. I keep it as a last resort.


    Code:
    #!/bin/bash
    # Stop v0.03
    
    if [ ! $1 ] ; then
            echo "Stop what?"
    else
            for i in `ps aux | grep -i $1 | grep -v grep | awk '{print $2}' ` ; do
            kill -9 $i
    done
    exit 0
    fi

    EDIT: Oh! I thought you said VLC. To kill it if it's not responding. I wouldn't know how a system responds when all VNC sessions receive the kill -9 signal. But it wont end nicely.
    Can't tell an OS by it's GUI

  6. #5
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,429
    Yes it will this is great =)
    Since if all the VNC close I wont have problems with VNC on Display 2 and stuff ^^

    Thanks

    Cheers,
    Robin
    New Users, please read this..
    Google first, then ask..

  7. #6
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,429
    I did Deploy it now, and it works WONDERFULL!! =)
    Thanks a lot... but.. for some reason my PC cant count anymore..
    It starts the vnc server now on xvnc:2 instead of 1..
    Weird stuff.. And when I try to start with vncserver:1 I get the value returned 127..

    Cheers,
    Robin
    New Users, please read this..
    Google first, then ask..

Posting Permissions

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