linux的进程启动方式有哪些类型

Linux的进程启动方式有很多种,主要包括以下几种:

1、命令行启动

linux的进程启动方式有哪些类型

2、脚本启动

3、服务启动

4、后台运行

5、系统启动项启动

6、用户级启动

7、系统级启动

8、图形界面启动

9、自动启动

linux的进程启动方式有哪些类型

10、定时启动

11、后台守护进程启动

12、前台运行

下面我们分别介绍这些启动方式的详细技术教程。

1、命令行启动

命令行启动是最简单的一种进程启动方式,通过在终端输入相应的命令,即可启动一个进程,要启动一个名为my_process的进程,可以在终端输入以下命令:

my_process &

&表示将进程放到后台运行,如果要让进程在前台运行,可以使用以下命令:

my_process -f &

2、脚本启动

linux的进程启动方式有哪些类型

脚本启动是通过编写一个脚本文件,然后在终端执行该脚本文件来启动进程,通常,脚本文件的第一行是用来指定解释器的路径,

#!/bin/bash

接下来,在脚本文件中编写需要执行的命令,

my_process &

给脚本文件添加可执行权限,并执行该脚本文件来启动进程:

chmod +x my_script.sh
./my_script.sh &

3、服务启动

服务启动是通过systemd或SysV init等系统管理工具来启动和管理进程,需要创建一个服务单元文件(通常是以.service结尾的文件),并在其中定义服务的配置信息,创建一个名为my_service.service的服务单元文件,内容如下:

[Unit]
Description=My Service Description
After=network.target
[Service]
Type=simple
User=myuser
ExecStart=/path/to/my_process &
Restart=always
RestartSec=5s
TimeoutStopSec=5s
SendSIGKILL=yes # Send kill signal if process exits without shutdown hook being executed (e.g. during a reboot)
KillMode=process # Kill the process by its process ID instead of its parent's process ID (default) or session ID (if possible) (see also 'killmode') and not by its job ID (which is what killall does). This behavior can be changed in future releases by modifying this option from the default value of "job" to one of "process", "parent", or "session". Note that killing a process with this mode may cause other processes to be killed as well (unless they are started after the killed process). Also note that this behavior differs from the old kill command which always kills the process by its job ID. The new kill command will still work but it may behave differently than expected in some cases. If you want to use the old behavior then set the KILLMODE environment variable to "old" when starting your service (see also 'killmode'). See the man pages for more information about these options. See also 'respawnlimit' and 'killmode' in systemd(1) and sysvinit(8). DefaultEnvironment="KILLMODE=old" # Use the old behavior when running systemd-based services (i.e. those using systemd(1)) or when no KILLMODE environment variable is set (i.e. those using sysvinit(8)). DefaultEnvironment="KILLMODE=process" # Use the new behavior when running systemd-based services (i.e. those using systemd(1)) or when the KILLMODE environment variable is set to "old" (i.e. those using sysvinit(8)). DefaultEnvironment="KILLMODE=parent" # Use the same behavior as before but kill the process by its parent's process ID instead of its own process ID (which is what killall does). DefaultEnvironment="KILLMODE=session" # Use the same behavior as before but kill the process by its session ID instead of its own process ID (which is what killall does). DefaultEnvironment="KILLMODE=none" # Do not kill any process when the service exits normally (i.e. when it returns a zero exit status). DefaultEnvironment="KILLMODE=auto" # Kill all processes that are not running at the time the service exits abnormally (i.e. when it returns a non-zero exit status). DefaultEnvironment="KILLMODE=full" # Kill all processes that are running at the time the service exits abnormally (i.e. when it returns a non-zero exit status). DefaultEnvironment="KILLMODE=range" # Kill all processes whose process ID falls within the range specified by the first and last arguments to this option (i.e. between start and end). DefaultEnvironment="KILLMODE=sameuser" # Kill all processes owned by the same user as this process (i.e. if this process is run under a different user then only those processes owned by that user will be killed). DefaultEnvironment="KILLMODE=samegroup" # Kill all processes owned by the same group as this process (i.e. if this process is run under a different group then only those processes owned by that group will be killed). DefaultEnvironment="KILLMODE=samesession" # Kill all processes in the same session as this process (i.e. if this process is run under a different session then only those processes in that session will be killed). DefaultEnvironment="KILLMODE=samehost" # Kill all processes on the same host as this process (i.th e if this process is run on a different host then only those processes on that host will be killed). DefaultEnvironment="KILLMODE=samemachine" # Kill all processes on the same machine as this process (i.th e if this process is run on a different machine then only those processes on that machine will be killed). DefaultEnvironment="KILLMODE=samepartition" # Kill all processes on the same partition as this process (i.th e if this process is run on a different partition then only those processes on that partition will be killed). DefaultEnvironment="KILLMODE=samefs" # Kill all processes on the same file system as this process (i.th e if this process is run on a different file system then only those processes on that file system will be killed). DefaultEnvironment="KILLMODE=samemountpoint" # Kill all processes on the same mount point as this process (i.th e if this process is run on a different mount point then only those processes on that mount point will be killed). DefaultEnvironment="KILLMODE=sameruntime" # Kill all processes running the same runtime as this process (i.t h e if this process is run under a different runtime then only those processes running that runtime will be killed). DefaultEnvironment="KILLMODE=sametype" # Kill all processes of the same type as this process (i.t h e if this process is run under a different type then only those processes of that type will be killed). Note that killing a process with this mode may cause other processes to be killed as well (unless they are started after the killed process). Also note that this behavior differs from the old kill command which always kills the process by its job ID (which is what killall does). See the man pages for more information about these options. See also 'respawnlimit' and 'killmode' in systemd(1) and sysvinit(8). DefaultEnvironment="KILLMODE=auto" # Use automatic selection of which KILLMODE to use based on whether or not there are any currently running instances of this service and which ones should be killed when it exits abnormally (i.e. when it returns a non-zero exit status). DefaultEnvironment="KILLMODE=full" # Kill all running instances of this service when it exits abnormally (i.e. when it returns a non-zero exit status). DefaultEnvironment="KILLMODE=sameuser" # Kill all instances of this service owned by the same user when it exits abnormally (i.th e if this process is run under a different user then only those instances owned by that user will be killed).DefaultEnvironment="KILLMODE=samegroup" # Kill all instances of this service owned by the same group when it exits abnormally (i.th e if this process is run under a different group then only those instances owned by that group will be killed).DefaultEnvironment="KILLMODE=samesession" # Kill all instances of this service in the same session when it exits abnormally (i.th e if this process is run under a different session then only those instances in that session will be killed).DefaultEnvironment="KILLMODE=samehost" # Kill all instances of this service on the same host when it exits abnormally (i.th e if this process is run on a different host then only those instances on that host will be killed).DefaultEnvironment="KILLMODE=samemachine" # Kill all instances of this service on the same machine when it exits abnormally (i.th e if this process is run on a different machine then only those instances on that machine will be杀死).DefaultEnvironment="KILLMODE=samepartition" # Kill all instances of this service on the same partition when it exits abnormally (i.th e if this process is run on a different

原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/121781.html

(0)
打赏 微信扫一扫 微信扫一扫
K-seo的头像K-seoSEO优化员
上一篇 2023-12-14 12:36
下一篇 2023-12-14 12:40

相关推荐

  • linux云主机登录密码怎么修改不了

    user是你的云主机用户名,your_cloud_host_ip是你的云主机IP地址,输入密码后,公钥将被复制到云主机上。

    2023-12-18
    0154
  • 扁平化设计个人网站_基于WordPress搭建个人网站(Linux)

    使用WordPress搭建个人网站,选择Linux系统,采用扁平化设计,简洁美观,易于维护。

    2024-06-18
    0113
  • linux rm删除文件

    在Linux系统中,删除文件或目录时,实际上并没有将文件或目录从磁盘上完全删除,而是将其标记为“已删除”,并释放了该文件或目录所占用的磁盘空间,这是因为在文件系统中,每个文件和目录都有一个索引节点(inode)记录其信息,包括文件大小、创建时间、权限等,当一个文件被删除时,只是将该文件的索引节点标记为“已删除”,而不是真正地将磁盘上的……

    2023-12-18
    0118
  • firstbyte-俄罗斯商家/荷兰KVM VPS月付111卢布/原生IP/测评

    俄罗斯商家提供荷兰KVM VPS,月付111卢布,原生IP,测评。

    2023-12-31
    04.2K
  • linux 磁盘管理命令

    在Linux系统中,磁盘管理是一个重要的环节,磁盘管理涉及到对磁盘分区、格式化、挂载等操作,本文将详细介绍Linux磁盘管理命令行的使用,帮助读者掌握Linux磁盘管理的基本技能。二、Linux磁盘管理命令行概述Linux磁盘管理命令行主要包括以下几个部分:1. 查看磁盘信息:fdisk、lsblk、df、du等命令;2. 磁盘分区:……

    2023-11-07
    0148
  • 怎样启动并进入Linux命令行

    在Linux操作系统中,命令行是一种非常强大的工具,它允许用户通过输入特定的命令来执行各种任务,对于初学者来说,启动并进入Linux命令行可能是一项具有挑战性的任务,但只要掌握了正确的步骤,这个过程就会变得非常简单,本文将详细介绍如何启动并进入Linux命令行。1、启动计算机你需要启动你的计算机,确保你的计算机已经安装了Linux操作……

    2023-12-27
    0128

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

免备案 高防CDN 无视CC/DDOS攻击 限时秒杀,10元即可体验  (专业解决各类攻击)>>点击进入