As an admin, you love to automate things. Lets say other users you have setup on your system run certain applications that may need to run in their own little shell. Instead of having to log into the server as that user (su’ing into a user and trying to create screen sessions doesn’t work very well) and making more work for yourself, you can actually (as root) start a screen session for the other user and define a command to run in the virtual terminal.

Check it out….

su -c "screen -fn -dmS mc /home/minecraft/startserver" minecraft

The above will start a screen session named “mc” and run the command “/home/minecraft/startserver” for the user “minecraft”.

Note that the screen session will not be created unless the application starts up successfully .

This is really nice for an rc.local entry upon booting your server to automatically start applications that don’t run as daemons.

Blog Logo

Mario Loria


Published

Image

./scriptthe.net

Because 127.0.0.1 gets old after a while.

Back to Overview