Solved Java PID ( Linux )

Discussion in 'Bukkit Help' started by GabriMagic, Oct 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    GabriMagic

    Its possible to select the PID to the process java when I run my server?
     
  2. Offline

    LokiChaos

    PID is assigned by the kernel, you cannot specify what it will be.

    As far as determining what the pid is:
    Code:
    java -jar somejar.jar &
    JAVAPID=$(pgrep -s 0 java)
     
  3. Offline

    GabriMagic


    The 0 is the pid that i can choose to the java process?
     
  4. Offline

    LokiChaos

    No, the -s 0 flag tells pgrep to only check the session of the parent shell when matching the process name.

    If you `pgrep java` you will list EVERY process with "java" somewhere in it, system/user-wide, which may or may not be the one you want. The shell variable $JAVAPID holds the PID of the process you launched in the first line (or should, if you have multiple child processes that contain 'java' it will contain them all.)

    Edit:
    man pgrep for more information on how to refine the search, but my example should work in the simple case of just one java child process.
     
  5. Offline

    GabriMagic

    Thanks for your idea, I do it with another thing but the same idea ^^ thanks

    Code:
    kill -9 $(ps aux | grep craftbukkit | head -1 | cut -d' ' -f6)
     
  6. Offline

    LokiChaos

    Ah, you just want to kill craftbukkit? 'pkill -signal 9 craftbukkit' is all you need.
     
  7. Offline

    GabriMagic

    hahhahha yeah for crashes is faster than "toop + k + PID", thaks for your help ^^
     
Thread Status:
Not open for further replies.

Share This Page