码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu 18.04 rc.local systemd设置

时间:2019-11-12 13:06:14      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:rip   touch   file   style   soft   配置文件   测试结果   main   can   

创建软链接

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。重启即可看到结果

Ubuntu 18.04 rc.local systemd设置

标签:rip   touch   file   style   soft   配置文件   测试结果   main   can   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!