cut*_*csc 4 php systemd centos7
我正在尝试在 centos7 启动时运行 phpscript。当前 systemd 进程如下所示
[Unit]
Description=custom Service
After=network.target
[Service]
Type=forking
User=root
ExecStart=/usr/bin/php /var/www/htdocs/mysite/public/index.php abc xyz >> /var/log/custom.log 2>&1
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
但是上面的脚本没有传递参数。我怎么能解决这个问题?谢谢!
作为替代方案,我创建了一个myphp.shbash 脚本
#!/bin/bash
nohup /usr/bin/php /var/www/htdocs/mysite/public/index.php abc xyz & >> /var/log/custom.log 2>&1
Run Code Online (Sandbox Code Playgroud)
然后在 systemd 脚本中
[Unit]
Description=custom Service
After=network.target
[Service]
Type=forking
User=root
ExecStart=/etc/init.d/myphp.sh
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)