linux init.d
Linux operating systems generally uses boot loader like grub
and lilo
and than uses init
process to start operating system and other services.init
is the most important process which forks or creates other process in a Linux system. init.d
is init
configuration directory which holds information about the services or daemons.
Linux操作系统通常使用grub
和lilo
类的引导加载程序,而不是使用init
进程来启动操作系统和其他服务。 init
是在Linux系统中派生或创建其他进程的最重要进程。 init.d
是init
配置目录,其中包含有关服务或守护程序的信息。
init.d位置 (init.d Location)
init.d
is located under /etc
which is configuration directory for most of the Linux distributions. We can chech the existence of the init.d
with the file
command like below. It is a directory of course.
init.d
位于/etc
,该目录是大多数Linux发行版的配置目录。 我们可以使用以下file
命令检查init.d
的存在。 这是一个目录。
$ file /etc/init.d
初始化守护进程(Init Daemon)
init
daemon is the first process of Linux system. Then other processes, services, daemons and threats are started by init
. So init.d
is a configuration database for init
process.
init
守护程序是Linux系统的第一步。 然后,其他进程,服务,守护程序和威胁由init
启动。 因此, init.d
是用于init
进程的配置数据库。
守护程序脚本 (Daemon Script)
Now we will print an example daemon process. A daemon script will hold functions like start
, stop
, restart
,status
etc. We will use cron
daemon script in this example.
现在,我们将打印一个示例守护进程。 守护程序脚本将包含start
, stop
, restart
, status
等功能。在本示例中,我们将使用cron
守护程序脚本。
$ cat /etc/init.d/cron
列出Init.d目录(List Init.d Contents)
There are a lot of different daemon and service scripts in init.d
directory. We can list these scripts with the ls
command like below.
init.d
目录中有很多不同的守护程序和服务脚本。 我们可以使用ls
命令列出这些脚本,如下所示。
$ ls /etc/init.d/
Init.d脚本用法(Init.d Script Usage)
We can use these daemon scripts just by calling the like a regular bash script. Lets print some help information by calling script but not providing any option.
我们可以像调用常规bash脚本一样使用这些守护程序脚本。 让我们通过调用脚本但不提供任何选项来打印一些帮助信息。
$ /etc/init.d/cron
and then list the status of the cron
daemon which is used for scheduled jobs.
然后列出用于计划作业的cron
守护程序的状态。
$ /etc/init.d/cron status
翻译自: https://www.poftut.com/what-is-init-d-and-how-to-use-for-service-management-in-linux/
linux init.d