Ubuntu15.04 systemd添加开机启动

1.在/lib/systemd/system/下添加启动文件

$ cd /lib/systemd/system/
$ sudo vim [email protected]

[email protected]内容为:

[Unit]
Description=Shadowsocks Client Start
After=network.target

[Service]
Type=simple
User=liuxu
ExecStart=/home/liuxu/.local/bin/sslocal -c /home/liuxu/.local/conf/shadowsocks/%i.json

[Install]
WantedBy=multi-user.target

[Unit]下设置了文件描述,启动顺序,在network启动以后,因为shadowsocks是代理,需要网络设置好了才能设置。

[Service]下设置Type启动模式,User设置启动用户,ExecStart为启动命令

[Install]下设置了启动模式,即老版的inittab。

2.将这个文件软连接到/etc/systemd/system/multi-user.target.wants/即可。

$ ln -s /lib/systemd/system/[email protected] /etc/systemd/system/multi-user.target.wants/[email protected]

$ ls -l /etc/systemd/system/multi-user.target.wants/[email protected]
lrwxrwxrwx 1 root root 44 12月 26 19:30 /etc/systemd/system/multi-user.target.wants/[email protected] -> /lib/systemd/system/[email protected]

猜你喜欢

转载自www.linuxidc.com/Linux/2016-04/129727.htm
今日推荐