Be it Firefox, a P2P client, a Java program, or whatever! Ubuntu makes it easy, but there's still some light editing to do (sorry, I don't know how to make these terminal commands yet).
For an example of how to make a Minecraft server (java app) auto-restart after crashing, see this post.
For everything else, see below:
Code via PID (Not all applications use a constant PID)
- Run the application
- Find the "ID" or PID (Process ID) in the System Monitor program (start bar > Systems > Administration)
- Create a document with the following code (anywhere on your machien), be sure to change the four purple pound symbols (#) to the process ID number you found.
Code:#!/bin/bash while true do if [ ! `PID ####` ] ; then /usr/bin/autorestart1.sh fi sleep 30 done- Create another document in the install folder of the application you wish to run. Title it "autorestart1.sh" with the following code
Code:cd (Path to install folder) Application File Name- <Important> You must change the "change directory" (cd) portion to direct terminal to your application's install folder
- <Important> You also must change the orange "Application File Name" to the actual name of the application you wish to run.
- Make a link to your "Start server.sh"
- Copy it
- Go to your /usr/bin as the root user (you can use Terminal's "sudo nautilus" browser to do this with a GUI).
- Paste the link and rename it "autorestart1.sh" (case sensitive)
- You're done!
Code via Process Name
A fair warning is that the only two ways to terminate the auto-restarting of the application is through killing the autorestart sh process or restarting your machine.
- Run the application
- Find the "Process Name" in the System Monitor program (start bar > Systems > Administration)
- Create a document with the following code (anywhere on your machien), be sure to change the purple "Process Name" to the process name you found.
Code:#!/bin/bash while true do if [ ! `pgrep Process Name` ] ; then /usr/bin/autorestart1.sh fi sleep 30 done- Create another document in the install folder of the application you wish to run. Title it "autorestart1.sh" with the following code
Code:cd (Path to install folder) Application File Name- <Important> You must change the "change directory" (cd) portion to direct terminal to your application's install folder
- <Important> You also must change the orange "Application File Name" to the actual name of the application you wish to run.
- Make a link to your "Start server.sh"
- Copy it
- Go to your /usr/bin as the root user (you can use Terminal's "sudo nautilus" browser to do this with a GUI).
- Paste the link and rename it "autorestart1.sh" (case sensitive)
- You're done!
Bookmarks