- Create a daemon configuration script under /etc/init ( NOT /etc/init.d ):-
nano /etc/init/mybot.conf
code sample:
description "MyBot Daemon"
author "alhazmy13"
start on startup
stop on shutdown
respawn
exec /usr/share/myScript.php
- alter your script file
myScript.php
and add below code at the top of the file:
#!/usr/bin/env php
<?php
#bash script
#while true; do ./myScript.php; done
$seconds = 5; $micro = $seconds * 1000000;
- at end of the file add:
usleep($micro);
- create symbolic link to /usr/share/
ln -s /var/www/html/myScript.php /usr/share
- after finish all those steps... now you can use " stop mybot | start mybot | status mybot " in terminal.
It would b helpful to automate things like DB or files backup consistently