centos开机启动脚本
nginx开机启动
cd /lib/systemd/system/
vim nginx.service
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl enable nginx
systemctl daemon-reload
###########################################
redis开机启动
vim /etc/systemd/system/redis-server.service
- [Unit]
- Description=redis-server
- After=network.target
- [Service]
- Type=forking
- ExecStart=/usr/local/redis/bin/redis-server /etc/redis/redis.conf
- PrivateTmp=true
- [Install]
- WantedBy=multi-user.target
#######################################
ElasticSearch开机启动
#!/bin/bash
#
#chkconfig: 345 63 37
#description: elasticsearch
#processname: elasticsearch-7.4.0
ES_HOME=/usr/local//usr/local/elasticsearch-7.4.0
case $1 in
start)
su es<<! 【es 这个是启动es的账户,如果你的不是这个记得调整】 cd $ES_HOME ./bin/elasticsearch -d -p pid
echo "elasticsearch is started"
;;
stop)
pid=`cat $ES_HOME/pid`
kill -9 $pid
echo "elasticsearch is stopped"
;;
restart)
pid=`cat $ES_HOME/pid`
kill -9 $pid
echo "elasticsearch is stopped"
sleep 1
su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
echo "elasticsearch is started"
;;
*)
echo "start|stop|restart"
;;
esac
exit 0