ก๊วนซอฟท์แวร์ </softganz> SoftGang (Gang Software)

Web &amp; Software Developer Gang.

Run PHP file as a service on Linux

by Little Bear @28 พ.ค. 69 15:02 ( IP : 171...205 )

#Create camera service

  • Create file /etc/systems/system/camera.service
[Unit]
Description=Flood Camera FTP Scan
# Requires=mysqld.service memcached.service
After=network.target

[Service]
User=username
Group=groupname
Type=simple
TimeoutSec=0
PIDFile=/var/run/php_camera_scan.pid
WorkingDirectory=/folder/to/working
ExecStart=/usr/local/php72/bin/php -f /folder/to/file.php  2>&1 > /folder/to/store/log/file.log
KillMode=mixed

Restart=on-failure
RestartSec=42s

[Install]
WantedBy=default.target

#Run service

systemctl start camera
systemctl stop camera
systemctl restart camera