Easy launch when loading a regular application (Java based) on Ubuntu Linux 8+ as a daemon
What is the easiest way to start an application when running on an Ubuntu server as a daemon? This is a Java application (java com.run.run.Run) etc.
How can I run it as a user and possibly have write access to some log file where the user has write permissions?
And if I don't, how do I run the application as root user at startup.
Edited: This is a headless server, I don't have access to desktop apps.
a source to share
As a user when logging in: Depends on exactly when you want it to start. Wanting to run it by the user and write the files as the user seems to indicate that you want to run it at login. This can be done 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 in ~/.profile
.
As root at boot: To run it as root at 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 that you want to run on boot, every time you boot. This will tell you how to do it.
Write a script. put it in /etc/init.d/ directory. Let's say you named it FOO. Then you run
% update-rc.d FOO by default
You should also create the generated file, FOO, executable using $ chmod + x FOO
a source to share
Using Headless mode in the Java SE platform can give you extra latitude, depending on what your daemon is doing. In addition to or @aioobe's suggestions, consider SuperUser.com download and permission questions.
a source to share