在centos7上使用最简单的方法把php脚本做成服务,随开机启动运行


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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM