系统启动时,使用rc.local文件启动程序是否正确? [英] Is it correct to use the rc.local file to start a program when the system starts?

查看:58
本文介绍了系统启动时,使用rc.local文件启动程序是否正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在系统启动时启动Java程序(class)(即使没有用户登录时).我阅读了一些文档,发现Linux在引导时执行了init命令,并在rc.d目录中执行了脚本.最后执行rc.local文件.因此,我想知道在系统完成启动后编辑此文件以运行应用程序是否正确?

I want to start a java program ( class ) when the system starts ( even though when no user has logged in the system ). I read some documentation and I found that Linux executes the init command when booting and executes the scripts in the rc.d directory. And the rc.local file is executed last. So I wonder if it is right to edit this file in order to run an application when the system has finished booting up ?

推荐答案

这要视情况而定.如果您的程序

It depends. If your program

  • 是纯粹的本地修改,并且
  • 您不需要守护程序来控制软件(稍后在系统运行时启动/停止它),并且
  • 一个简单的SIGTERM足以在系统关闭时停止程序,

然后是的,rc.local只是放置它的要点.

then yes, rc.local is just the point to put it.

如果打算在其他系统上安装该文件,请将文件放在/etc/init.d中,并使用系统特定的命令使它在适当的运行级别运行.

If you intend to install the file on other systems, put a file in /etc/init.d and use the system specific commands to let it run at the appropriate runlevels.

这篇关于系统启动时,使用rc.local文件启动程序是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆