Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was just wondering how(if it's possible) I could go about create a bash file to launch a mono app on system start, and have it open back up if it crashes. Is there some kind of while loop I could create or something? Just so you know I have no GUI, this is all ssh command prompt. Also it's Ubuntu 10.10. Keep in mind for this question, I don't know how to start things on system start and I know nothing of bash(other than it exists).

Thanks.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You will probably want to use the Upstart system which is what is used on Ubuntu to manage system services that need to start at system startup and be kept running while the system is up.

You can look at the files in /etc/init/ to use as models. In particular, these files are among those that use the respawn instruction which keeps daemons running if they crash: cron.conf, dbus.conf, hal.conf and udev.conf.

Some of those files have corresponding entries in /etc/init.d that are symlinked to /lib/init/upstart-job. Others have their own shell script. These are used to manage starting and stopping the daemon and can be used as models for your own script.

Please see this for more information on Upstart.

Please see this for more information on Process Management (although it doesn't include any Upstart information, it does have other useful tips).

Please feel free to ask additional separate questions about specific aspects of making use of this feature. If you have brief follow-ups, you can post them as comments or edits to your question, of course.

share|improve this answer
    
I know this is a little bit off topic, but is there a way to log output from a program? Like say a program in the background crashes, and says something like "Error. Program crash" to the command line, is there a way to catch that and log it? –  kelton52 Feb 28 '11 at 22:44
    
@kelton52: program 2>/path/to/err.log will write the error output of the program to the file. program > /path/to/out.log will write the regular output to the file. To combine them: program > /path/to/out.log 2>/path/to/err.log or program > /path/to/everything.log 2>&1 –  Dennis Williamson Mar 1 '11 at 0:07
    
That's great, thanks a lot! Little things like that make me love linux. –  kelton52 Mar 1 '11 at 3:02
    
@kelton52: If you found my answer to be helpful, please mark it as accepted. Thanks. –  Dennis Williamson Mar 1 '11 at 3:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.