Here is a neat trick. If you want to start a program that always respawns if it gets killed, just put it in
init process will respawn the program. That's what it's for.
Here's an example. Let's say you want
/bin/unkillable to always run. Put this in
init q to make init re-read the inittab file. Now whenever
/bin/unkillable gets killed, init will respawn it.
The init process uses this same trick to spawn terminals (otherwise if the terminals died and no one respawned them, no one would be able to log in from the physical terminals). This approach is also very useful if you absolutely must have some programs running. You don't even need complicated tools such as daemontools or supervisor to respawn programs. In most cases this trick is enough.
More information about init and /etc/inittab can be found in
man init and
man inittab. Until next time.
- by unkillable I mean one that respawns when you kill it.