linux service

service与chkconfig的替代者systemctl

https://blog.csdn.net/itcomputer12/article/details/41799139

systemctl创建 service

https://blog.csdn.net/gbenson/article/details/51083817

https://blog.csdn.net/qq_14852397/article/details/71794574?locationNum=11&fps=1

https://blog.csdn.net/chwshuang/article/details/68489968

创建Redis服务过程

sudo vi /lib/systemd/system/redis.service

[Unit]
Description=Redis
After=network.target

[Service]
ExecStart=/opt/redis-4.0.9/src/redis-server /opt/redis-4.0.9/redis.conf  --daemonize no
ExecStop=/opt/redis-4.0.9/src/redis-cli -h 127.0.0.1  -p 6379 -a ${password}  shutdown

[Install]
WantedBy=multi-user.target

运行shell

systemctl daemon-reload
systemctl enable redis
systemctl start redis

注:
systemctl enable redis 相当于执行了: ln -s /lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service

查看开机启动项

http://www.cnblogs.com/end/archive/2012/10/12/2721059.html

sudo apt-get install sysv-rc-conf
sysv-rc-conf

systemctl list-unit-files

列出所有状态 : service --status-all

启动sshd服务

service sshd start

设置sshd服务开机启动

chkconfig sshd start

posted @ 2018-04-17 09:58  NewSea  阅读(185)  评论(0编辑  收藏  举报