|
|
vim /lib/systemd/system/rc-local.service
/ J0 G6 Z% K) D2 a- Y( w) R; g3 l
[Unit]
& Z% [- d6 j' L4 }1 P1 L! ?5 QDescription=/etc/rc.local Compatibility; Y1 F9 e9 g, Q' _# Q: Q f' g
Documentation=man:systemd-rc-local-generator(8)
# j! t$ |9 x' M4 B' ?1 zConditionFileIsExecutable=/etc/rc.local3 y% M# m$ t1 u8 H/ d- k
After=network.target
4 E5 J; N j* I5 @) g% D1 z/ w5 f- W! B[Service]1 e/ }: {. F: e' y1 \" S
Type=forking
0 P; a; h; u" ]2 X+ |# wExecStart=/etc/rc.local start( H& ^+ p) v* O2 {: Y# L
TimeoutSec=0
. w" r+ \# R" zRemainAfterExit=yes- _. E) `3 B# r: K% J
GuessMainPID=no4 L# ]. D$ w2 j; L# Y- _
, D, K2 I% K7 c0 k& l
在后面添加:
, n5 | ^/ E# h) Q2 L4 Q[Unit]' Y& \! h: c( ~' A
Description=/etc/rc.local Compatibility
4 c1 q' G$ k4 |8 ~) z/ C) c0 k& WDocumentation=man:systemd-rc-local-generator(8)
& M. W) g U; }" L2 q0 x! HConditionFileIsExecutable=/etc/rc.local
2 t6 s6 F; h: mAfter=network.target) M$ [ d5 L) g9 y1 Z
[Service]) m, t1 u% k, a" U$ D0 N# `" @
Type=forking& T" Q7 A, t* d& X8 ]. R% C/ q* p
ExecStart=/etc/rc.local start
# e: H. S: H: M' x9 L) c r* dTimeoutSec=03 `' v. d* q4 N. f1 ~% ?0 i9 T
RemainAfterExit=yes6 C F* k9 Y0 _+ y/ }. m
GuessMainPID=no; G1 ^+ r& v3 B3 G
[Install]
# w- R+ W* H" W) m# y5 MWantedBy=multi-user.target( W) ~: T+ o' R' N8 B% ?8 X; l% D) M
Alias=rc-local.service
$ _) |+ K( U4 ^) c/ N
" Y4 c0 K/ c4 m" n" b$ d" g保存退出;& J2 q T V8 s" g! L. _
& A4 ]6 B1 [/ }$ T5 H/ ~编辑rc.local文件:
1 C- ?, s3 G' }/ bvim /etc/rc.local " a- g6 H1 s. ~% D9 L) Y) A4 Z1 a2 Z2 R
添加需要添加的文件:& F! n6 ]4 z5 z6 f9 O& P/ Q/ @' i; b) i
; d( Y- A$ c7 @给文件添加执行权限:2 U4 b& t( s" D$ O& W
root@localhost:~# chmod +x /etc/rc.local. u# s$ G. E* g' U! y) V+ |
1 I/ Q2 U- R$ ]8 N" d5 M# q" @. A3 l* G9 J# A! a; I. X2 D( N
添加软连接:
6 D# {6 u! D$ k6 v" R+ fln -sf /lib/systemd/system/rc-local.service /etc/systemd/system/. P8 `: _6 @8 Q0 N
( i! g- \, H, a7 i2 P# ~
4 U; G4 L% g, |9 `& R2 V; Q重启服务即可。/ b2 U! {! B4 k4 `
|
|