Save this as, respawn.sh:
CODE
#!/bin/sh
while [ 1 ]; do
/bin/ls -l /home/znx
done
while [ 1 ]; do
/bin/ls -l /home/znx
done
Now execute it like this:
CODE
$ ./respawn.sh
Now the screen will fill with lots and lots of ls information. Ctrl+C will kill it for you. This is an example of a neverending loop. Now where would you want this? Well the reason that I'm writing this is that I recently helped Blue|Moon setup this to ensure that a Counter Strike Source server would keep running:
CODE
#!/bin/sh
while [ 1 ]; do
cd /path/to/install
./srcds_run -game cstrike ..... the rest of your options ......
done
while [ 1 ]; do
cd /path/to/install
./srcds_run -game cstrike ..... the rest of your options ......
done
Started with:
CODE
$ cd /path/to/install
$ screen -m -d -S sourceserver ./respawn.sh
$ screen -m -d -S sourceserver ./respawn.sh
Now when the server quits or is killed, another takes its place, saving you the user from having to login remotely and start it all the time
