1、编辑service_name.service文件,内容如下:
[Unit]
Description=Your Beanstalk Consumer
After=network.target
[Service]
ExecStart=/usr/bin/php /path/to/your/consumer-script.php
Restart=always
User=your_user
[Install]
WantedBy=multi-user.target
2、将文件拷贝到目录下
cp service_name.service /etc/systemd/system/
3、启动自动启动
systemctl enable service_name
4、启动守护进程
systemctl start service_name
