從Ubuntu 14.04升級到Ubuntu 15.04後,rc.local無效了,因為Ubuntu 15.04使用了systemd管理開機啟動,於是從新設置我的shadowsocks開機啟動。
1.在/lib/systemd/system/下添加啟動文件
$ cd /lib/systemd/system/
$ sudo vim [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]
CentOS7/RHEL7 systemd詳解 http://www.linuxidc.com/Linux/2015-04/115937.htm
為什麼systemd會被如此迅速的采用? http://www.linuxidc.com/Linux/2014-08/105789.htm
systemd 與 sysVinit 彩版對照表 http://www.linuxidc.com/Linux/2014-09/106455.htm
太有用了!用systemd命令來管理Linux系統! http://www.linuxidc.com/Linux/2014-09/106490.htm
淺析 Linux 初始化 init 系統,第 3 部分: Systemd http://www.linuxidc.com/Linux/2014-12/110383.htm