If you have a process that needs to continually run on a GNU/Linux computer, or an app that needs to reopen after an occasional crash, or the like, you can create a simple script that will run 'program' until you manually interrupt this command with the [Ctrl][C] keyboard combo.
shell# while true; do program; done
An example of this may be to relaunch Firefox after closing it, on a public computer for example, where we want it to always be up and running for the visitors:
shell# while true; do /usr/bin/firefox && pkill firefox; done
The && means to run the next command when the first finishes, and the pkill firefox makes sure to close off any remaining processes before reevaulating the 'while true' statement (which is always true because we've not put in any conditions) and therefor relaunching Firefox.
0 comments:
Post a Comment