1、准备文件:coffeetest.service
# copy to /usr/lib/systemd/system # systemctl enable coffeetest.service [Unit] Description=coffeetest Service [Service] Type=forking User=root ExecStart=/etc/init.d/coffeetest.sh [Install] WantedBy=multi-user.target
2、准备文件:coffeetest.sh
#!/bin/bash nohup /usr/bin/php /myproject/coffeetest.php >> /myproject/logs/coffeetest.log 2>&1 &
拷贝到目录:/etc/init.d