Home Fedora 开机启动运行脚本
Post
Cancel

Fedora 开机启动运行脚本

引言

千万不要把死循环放进去啊!!!使用 systemd 方式

新建脚本

在此文件中写入您的脚本

1
vi /etc/rc.d/rc.local

赋予执行权限

1
chmod +x /etc/rc.d/rc.local

编辑启动状态

编辑文件

1
vi /usr/lib/systemd/system/rc-local.service

在最后一行加入 [Install]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

然后使用 systemd 开机自启动

1
systemctl enable rc-local.service 

查看启动状态

使用以下命令

1
systemctl status rc-local.service

参考文章

Fedora 22(15以上版本)开机自启动脚本 - 可酷可乐 - 博客园

This post is licensed under CC BY 4.0 by the author.

JavaScript 学习

HTML 学习二 - 列表、表格与表单