linux 设置开机启动

centos 6

编辑 /etc/rc.local  加入要起动的命令

例如:

vim /etc/rc.local 
ssserver -c /etc/ss.json -d start 
然后保存退出即可 
给予开机权限
chmod +x /etc/rc.d/rc.local
chmod +x /etc/rc.local

centos 7

在/etc/systemd/system 目录下面建立xxxx.service,例如shadowsocks.service
编辑此文件
[Unit]
Description=Shadowsocks #命名
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/ssserver -c /etc/shadowsocks.json -d start
ExecStop=/usr/bin/ssserver -c /etc/shadowsocks.json -d stop
[Install]
WantedBy=multi-user.target


给此文件权限
cd /etc/systemd/system
chmod 755 shadowsocks.service

启动
systemctl start shadowsocks
开机自动运行
systemctl enable shadowsocks
停止开机自启动
systemctl disable shadowsocks
停止
systemctl stop shadowsocks
重启
systemctl restart shadowsocks

猜你喜欢

转载自blog.csdn.net/wuxing164/article/details/80996171