views:

324

answers:

2

What is the easiest way to have an application launch at startup on Ubuntu server as daemon? This is a java application (java com.run.run.Run) etc.

How would I have it launch as a user and possibly have access to write to some log file where the user has permissions to write?

And if I don't end up doing that, how would I launch the application as the root user at startup.

Edited: It is a headless server, I don't have access to the desktop applications.

+1  A: 

As user upon login: Depends on when exactly you want it to start. Wanting to run it a a user and write files as the user seems to indicate that you want to run it at login. This can be achieved by adding it under

System -> Preferences -> Sessions -> Statup Programs 

or

System -> Preferences -> Startup applications

Depending on your version of gnome.

Or, put a call to your java program it in ~/.profile.


As root upon boot: To run it as root during boot, follow the instructions at http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/

So you have a script of your own that you want to run at bootup, each time you boot up. This will tell you how to do that.

Write a script. put it in the /etc/init.d/ directory. Lets say you called it FOO. You then run

% update-rc.d FOO defaults

You also have to make the file you created, FOO, executable, using $chmod +x FOO

aioobe
I should have mentioned I don't have access to the gui applications.
Berlin Brown
A: 

Using Headless Mode in the Java SE Platform may give you some additional latitude, depending on what your daemon does. In addition or @aioobe's suggestions, consider SuperUser.com for questions about startup and permissions.

trashgod