centos

centos进程启动脚本在哪里编辑

小樊
45
2025-11-22 01:39:13
栏目: 智能运维

CentOS 进程启动脚本编辑位置与方式

按系统版本选择编辑位置

systemd 服务文件位置与最小示例

[Unit]
Description=My Application
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/myapp.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable myapp.service
sudo systemctl start  myapp.service
sudo systemctl status myapp.service

SysV init 脚本位置与 chkconfig 用法

#!/bin/sh
# chkconfig: 2345 70 30
# description: My custom service
# processname: myapp
chmod +x /etc/init.d/myapp
chkconfig --add myapp
chkconfig myapp on

如何选择

0
看了该问题的人还看了