LoginSignup
16

More than 3 years have passed since last update.

posted at

updated at

ubuntu 18.04 で rc.local を使う

ubuntu 18.04 で rc.local を使うには、/etc/rc.local を作成し、chmod u+x する。

/etc/rc.local
$ ls -l /etc/rc.local
-rwxr--r-- 1 root root 60 Feb 20 13:25 /etc/rc.local
$ cat /etc/rc.local
#!/bin/sh

echo hogehoge...

$

systemd で管理されていていて、その内容は以下の通り。

/lib/systemd/system/rc-local.service

#  SPDX-License-Identifier: LGPL-2.1+
#
#  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.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
16