How to run a program and get its PID in the background
        Posted  
        
            by 
                Ivan
            
        on Super User
        
        See other posts from Super User
        
            or by Ivan
        
        
        
        Published on 2013-10-28T21:09:01Z
        Indexed on 
            2013/10/28
            21:57 UTC
        
        
        Read the original article
        Hit count: 329
        
I have a Minecraft server startup script that looks like this:
#!/bin/bash
cd "$(dirname "$0")"
exec java -Xmx4096M -Xms4096M -jar minecraft_server.jar
How do I get java process's PID while being able to enter input into the Java process?
if I change the exec line to
exec java -Xmx4096M -Xms4096M -jar minecraft_server.jar & echo $! > pid
it won't let me input any text into the Minecraft server java process.
© Super User or respective owner