Tag Archives: CentOS7

CentOS7系统服务脚本编写

    最近开始把玩CentOS 7,发现之前的部分服务启动脚本在新版OS中运行异常(报错),特意摸索了下,个人感觉7的服务自启动脚本编写非常简单方便。
# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx – high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/usr/sbin/nginx -s stop
[Install]
WantedBy=multi-user.target
# systemctl status nginx.service 查看服务当前状态
# systemctl enable nginx.service 设置开机自启动
# systemctl list-units –type=service 查看所有已启动的服务

Continue reading »