Ubuntu 18.04 rc.local systemd设置

创建软链接

ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service  

编辑配置文件

vim /etc/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  

[Install]
WantedBy=multi-user.target
Alias=rc-local.service 

创建rc.local文件

touch /etc/rc.local
chmod 755 /etc/rc.local 

测试结果

#!/bin/bash  

echo "test rc " > /var/test.log  

注意:一定不要去执行systemctl enable rc-local。重启即可看到结果

原文地址:https://www.cnblogs.com/guge-94/p/11841088.html

时间: 2024-07-29 09:14:54

Ubuntu 18.04 rc.local systemd设置的相关文章

Ubuntu 18.04 LTS IP 地址设置

和之前的版本不太一样, Ubuntu 18.04 的 ip地址设置是用netplan管理的 配置文件在: /etc/netplan/50-cloud-init.yaml 示例文件如下: # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network

Ubuntu 18.04 系统U盘安装与初步设置

Ubuntu 18.04 系统U盘安装与初步设置一.Ubuntu 18.04 单系统U盘安装二.其他设置开启ROOT账号,设定IP地址,安装启动Telnet,修改时区Ubuntu 18.04 单系统U盘安装一. Ubuntu 18.04 u盘启动盘制作? 制作环境Windows 10? Ubuntu系统镜像 ubuntu-18.04.2-live-server-amd64.iso(https://ubuntu.com/download/server)? U盘 我使用32G? 软件 rufs-3.

ubuntu 18.04 配置 rc.local

ubuntu 18.04 配置 rc.local:https://blog.csdn.net/a912952381/article/details/81205095 Ubuntu /etc/rc.local 不存在: https://blog.csdn.net/weixin_43599336/article/details/85970601 原文地址:https://www.cnblogs.com/dhcn/p/10660465.html

Ubuntu 18.04设置dns

最近使用了最新版的ubuntu 18.04运行一些服务,然后发现服务器经常出现网络不通的情况,主要是一些域名无法解析. 检查/etc/resolv.conf,发现之前修改的nameserver总是会被修改为127.0.0.53,无论是改成啥,过段时间,总会变回来. 查看/etc/resolv.conf这个文件的注释,发现开头就写着这么一行: # This file is managed by man:systemd-resolved(8). Do not edit. 这说明这个文件是被syste

Ubuntu 18.04 Numix主题设置

Ubuntu 18.04 Numix主题设置 一.首先安装Numix主题 展现效果如下图 1.安装numix sudo add-apt-repository ppa:numix/ppa 2.安装主题 sudo apt-get install numix-gtk-theme numix-icon-theme-circle 3.如果没有tweak可以先安装一个tweak sudo apt-get install gnome-tweak-tool 打开Tweak 设置下载的主题Numix主题,图标设置

Ubuntu 18.04 设置固定的静态ip

系统版本: [email protected]:/# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04 LTS Release: 18.04 Codename: bionic [email protected]:/# 之前的版本网卡配置信息配置在/etc/network/interfaces文件,可以如下配置, auto ens33 iface ens33 i

ubuntu 18.04 - server版 开机启动脚本

ubuntu 18.04 不再使用 inited 管理系统,改用 systemd systemd 默认读取 /etc/systemd/system 下的文件,该目录下的文件会链接/lib/systemd/system/下的文件. 执行 ls /lib/systemd/system 你可以看到有很多启动脚本,其中就有我们需要的 rc.local.service 打开脚本内容: [Unit] Description=/etc/rc.local Compatibility ConditionFileI

在Ubuntu 18.04上安装MongoDB

第1步 – 导入公钥 Ubuntu软件包管理器apt(高级软件包工具)需要软件分销商的GPG密钥来确保软件包的一致性和真实性. 运行此命令将MongoDB密钥导入到您的服务器. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 第2步 – 创建源列表文件MongoDB 使用以下命令在/etc/apt/sources.list.d/中创

【ubuntu】Ubuntu 18.04中重启php7.3方法

Linux环境:Ubuntu 18.04 x64 安装方式:sudo apt-get install php7.3 (默认安装的7.3.6版本) [查看php-fpm状态] systemctl status php-fpm systemctl status php7.3-fpm [查找php-fpm服务] sudo find / -name '*fpm.service' 查看php-fpm服务配置如下: cat /lib/systemd/system/php7.3-fpm.service 内容如