Linux下Redis开机自动启动脚本

  • /etc/systemd/system下创建redis.service
  • 设置为可执行脚本chmod +x redis.service
[Unit]
Description=Redis Server Manager
After=network.target

[Service]
Type=simple
User=root
Group=root
PIDFile=/var/run/redis_6379.pid # 指定 redis.pid 路径
ExecStart=/home/redis/bin/redis-server /home/redis/redis.conf
ExecStop=/home/redis/bin/redis-server -s stop
Restart=always

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload     # 重新加载配置
sudo systemctl enable redis.service      # 设置开机自启

来源链接:https://www.cnblogs.com/osinn/p/18807708

请登录后发表评论

    没有回复内容