This provides a nice way to run and respawn a program on a virtual console, instead of using getty and login like you normally would on a vc.

I use it with the quake2 server. I first created a "quake2" user, so I can run the server program as that user instead of "root".

First, run "make" to build the "q2getty" program and install it, i.e. in /usr/local/bin.

The first argument to the program is the /dev/ttyN to run it on, i.e. "tty3". The second is the user to run as. Use "root" if you're too lazy to set one up. The third and subsequent arguments are used to run the subprogram.

I then replaced virtual console #3's getty entry (tty3) in /etc/inittab with:

3:2345:respawn:/usr/local/bin/q2getty tty3 quake2 /home/quake2/quake2 +set dedicated 1

(Actually, I replaced the "/home/quake2/quake2 +set dedicated 1" part with the path of a shell script that launches it, but you get the point.)

After finishing the edits to /etc/inittab, do "init q" to commit the changes, however, you still may need to kill off the "getty" process that was running on tty3. "ps aux | fgrep getty" and kill that process.

This now runs the quake2 server program on console 3 (ALT-F3). You can also switch to that console to view output or type input.

Why to use it

If the server process happens to die, it will be respawned automatically. So, in the rare case that the process dies, you don't have to be there to restart it manually.

You don't have to leave a live window running on your machine, so there's no danger of someone killing the q2 server and being left at a shell prompt.

So although it runs in the background, you can still switch to the console and type commands to the q2 shell.


Download the source code for version 1.0 here.

See Also

  • Linux Quake HOWTO and FAQ
  • Linux Quake and Utilities
  • TraySpy (for Windows)

  • Back to NcFTP Software's UnixStuff