PDA

View Full Version : Linux Server - Run in background


morphene
05-31-2004, 03:34 AM
Hey Everyone. :)

I've just set up my own box, and can start my server at the command prompt like so:

./cod_lnxded +map_rotate

Which works fine, although if I close the console window, the server will close.

So, from reading a few websites, I created a start.sh script with the following code called start.sh:

#!/bin/bash
#
gamedir=/usr/local/games/cod
pidfile=CoD.pid

cd $gamedir
if [ -f $pidfile ]; then
kill -0 `cat $pidfile` >/dev/null 2>&1
if [ $? -ne 0 ]; then
./cod_lnxded +map_rotate >/dev/null 2>&1
fi
else
./cod_lnxded +map_rotate >/dev/null 2>&1
fi

When i run it with:

./start.sh &

I get:

server# ./start.sh &
[1] 12083
server# ./start.sh: Command not found.

I am running FreeBSD if that helps anyone. Would appreciate any comments, or alternatives to running the server in the background so that the console window can be closed.

Thanks everyone :)

Kill_Control
06-01-2004, 08:58 PM
perhaps your permissions are not set right.

chmod 766 start.sh

or

chmod +x start.sh

Glanzer
06-10-2004, 11:41 AM
Try running the shell script in the same shell to get more specific errors for debugging purposes, like this:

source start.sh

Actually, I'm wondering if it can't find your bash shell binary at /bin/bash, shouldn't that first line be the following?

#!/bin/sh