Running Scripts on Fedora Boot

📢 This article was translated by gemini-2.5-flash

Introduction

Seriously, don’t put infinite loops in here!!! We’re using the systemd way.

Create the Script

Write your script in this file:

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

Grant execute permissions:

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

Edit Startup Status

Edit the file:

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

Add [Install] to the last line:

 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

Then enable it for boot with systemd:

1
systemctl enable rc-local.service 

Check Startup Status

Use the following command:

1
systemctl status rc-local.service

References

Fedora 22 (and above 15) Boot Auto-Start Script - Kekukele - Blog园

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