首页 > 系统相关 >在AMD PetaLinux的systemd里启动后台命令的注意事项

在AMD PetaLinux的systemd里启动后台命令的注意事项

时间:2023-08-07 16:13:10浏览次数:35  
标签:systemd forking service process AMD up 后台 PetaLinux

由于客户需要,需要在Linux里启动服务,使一个脚本在后台一直运行。

于是创建一个systemd服务,使其运行顶层脚本,再在其中以后台运行方式启动另外一个长期运行脚本。

结果发现,后台运行的长期运行脚本,过一段时间也退出了。

经过调试和分析,发现systemd创建的后台进程,以“Type=forking”方式运行,就不会退出。

按文档 systemd.service , “Type=forking” 表示子进程作为服务的主进程。这说明以“Type=forking”方式运行的后台进程,是正确的模式。

 •   If set to forking, it is expected that the process
               configured with ExecStart= will call fork() as part of
               its start-up. The parent process is expected to exit when
               start-up is complete and all communication channels are
               set up. The child continues to run as the main service
               process, and the service manager will consider the unit
               started when the parent process exits. This is the
               behavior of traditional UNIX services. If this setting is
               used, it is recommended to also use the PIDFile= option,
               so that systemd can reliably identify the main process of
               the service. systemd will proceed with starting follow-up
               units as soon as the parent process exits.

标签:systemd,forking,service,process,AMD,up,后台,PetaLinux
From: https://www.cnblogs.com/hankfu/p/17611696.html

相关文章

  • 在AMD PetaLinux中添加命令pstree
    命令pstree将相关进程以树状图显示,方便查看进程间的关系。由于调试需要,需要在Linux里使用命令pstree。但是PetaLinux产生的Linux映像,默认不带命令pstree。在rootfs里查找pstree首先使用命令“petalinux-config-crootfs”尝试在rootfs里查找pstree。没有找到pstree。在psmisc......
  • AMD cpus在VM虚拟机安装macOS10.15和12教程一
    本教程采用软件为vmwareworkstation17pro,操作系统win10,CPU为5600G,macOS10.15或者macOS12VM虚拟机的下载和安装这里不阐述,大家可以百度一下macos13在上述环境下安装后会提示错误,macOS14beta暂时不支持安装,所以13-14可以暂时放弃macOS的下载请百度一下就有了~记得下载带引导......
  • 14_systemd
    systermd大多数现代Linux发行版都使用systermd(systermmanagementdeamon)作为默认的初始系统和服务管理器.systermd是Linux初始化系统管理、日志记录、启动管理器等等。systermd是第一个进程,它会接管并继续挂载主机文件系统和启动服务。在进程列表中,为了向后兼容,列表把syst......
  • frp 树莓派通过systemd设置开机启动
    树莓派操作系统为xxx@raspberrypi:$cat/etc/os-releasePRETTY_NAME="DebianGNU/Linux11(bullseye)"NAME="DebianGNU/Linux"VERSION_ID="11"VERSION="11(bullseye)"VERSION_CODENAME=bullseyeID=debianHOME_URL="https:......
  • Linux systemd配置
    介绍:systemd是Linux系统工具,用来启动守护进程,已成为大多数发行版的标准配置。它是一个初始化程序(init)和SystemV初始化脚本的现代替代者。Systemd可以接管后台服务、结束、状态查询,以及日志归档、设备管理、电源管理、定时任务等许多职责。Systemd是所有进程之母,负责将Linux主......
  • Systemd教程
    title:"Systemd教程"date:2023-07-31T16:05:25+08:00tags:["Linux运维"]categories:[]draft:falseSystemd入门教程:实战篇-阮一峰的网络日志配置文件$systemctlcatsshd.service[Unit]Description=OpenSSHserverdaemonDocumentation=man:sshd(8)man:ssh......
  • 官方实锤!AMD真的已经有了大小核:不搞Intel那一套
    Intel12代酷睿开始引入大小核混合架构,多核跑分提升立竿见影,在游戏、渲染等场景中也有很好的辅助作用,但因为大核心、小核心基于完全不同的架构,需要复杂的系统、软件调度配合,也直接导致失去了AVX-512指令集。AMD也早就确认在开发自己的大小核,并强调两种核心会是完全相同的架构、IP......
  • 使用 systemd timer 备份数据库
    定义timer文件进入目录/usr/lib/systemd/system,按如下文件建立timer:[Unit]Description=Runsdbbackupeveryhour[Timer]#TimetowaitafterbootingbeforewerunfirsttimeOnBootSec=10min#TimebetweenrunningeachconsecutivetimeOnUnitActiveSec=1hUnit=db_b......
  • Systemd 入门教程
    Systemd入门教程:命令篇Systemd是Linux系统工具,用来启动守护进程,已成为大多数发行版的标准配置。本文介绍它的基本用法,分为上下两篇。今天介绍它的主要命令,下一篇介绍如何用于实战。一、由来历史上,Linux的启动一直采用init进程。下面的命令用来启动服务。$sudo/et......
  • 骚操作之——lamda表达式
    Lambda表达式是一种用于简化函数定义的语法结构,它可以将一个匿名函数作为参数传递给其他函数或方法。以下是一些常见的Lambda表达式的用法,以及一个例子:1.列表排序:List<Integer>numbers=Arrays.asList(5,2,1,3,4);numbers.sort((a,b)->a.compareTo(b));```2.......