Ubuntu Linux 8 上杂项应用程序(基于 Java)的简单启动作为守护进程

发布于 2024-08-31 19:13:44 字数 198 浏览 10 评论 0 原文

在 Ubuntu 服务器上启动应用程序作为守护进程启动时最简单的方法是什么?这是一个java应用程序(java com.run.run.Run)等。

我如何让它以用户身份启动,并可能有权写入用户有权写入的某些日志文件?

如果我最终不这样做,我将如何在启动时以根用户身份启动应用程序。

编辑:这是一个无头服务器,我无权访问桌面应用程序。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮萍、无处依 2024-09-07 19:13:44

作为登录用户:
取决于您希望它何时开始。想要以用户身份运行它并以用户身份写入文件似乎表明您想要在登录时运行它。 下来实现

System -> Preferences -> Sessions -> Statup Programs 

这可以通过将其添加到或

System -> Preferences -> Startup applications

,具体取决于您的 gnome 版本。

或者,在 ~/.profile 中调用您的 java 程序。


启动时以 root 身份运行:要在启动时以 root 身份运行它,请按照 http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup /

因此,您有一个自己的脚本,希望在每次启动时运行。这将告诉您如何做到这一点。

编写脚本。将其放在 /etc/init.d/ 目录中。
假设你称之为 FOO。然后你运行

% update-rc.d FOO 默认值

您还必须使您创建的文件 FOO 可执行,使用
$chmod +x FOO

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

玩心态 2024-09-07 19:13:44

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文