Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li><p>You could run the script with the following command: </p> <pre><code>nohup php /var/www/development_folder/scripts/push2/push.php &gt; /dev/null &amp; </code></pre> <p>The nohup means that that the command should not quit (it ignores hangup signal) when you e.g. close your terminal window. If you don't care about this you could just start the process with "php /var/www/development_folder/scripts/push2/push.php &amp;" instead. PS! nohup logs the script output to a file called nohup.out as default, if you do not want this, just add > /dev/null as I've done here. The &amp; at the end means that the proccess will run in the background. I would only recommend starting the push script like this while you test your code. The script should be run as a daemon at system-startup instead (see 4.) if it's important that it runs all the time.</p></li> <li><p>Just type</p> <pre><code>ps ax | grep push.php </code></pre> <p>and you will get the processid (pid). It will look something like this:</p> <pre><code>4530 pts/3 S 0:00 php /var/www/development_folder/scripts/push2/push.php </code></pre> <p>The pid is the first number you'll see. You can then run the following command to kill the script:</p> <pre><code>kill -9 4530 </code></pre> <p>If you run ps ax | grep push.php again the process should now be gone.</p></li> <li><p>I would recommend that you make a cronjob that checks if the php-script is running, and if not, starts it. You could do this with ps ax and grep checks inside your shell script. Something like this should do it:</p> <pre><code>if ! ps ax | grep -v grep | grep 'push.php' &gt; /dev/null then nohup php /var/www/development_folder/scripts/push2/push.php &gt; /dev/null &amp; else echo "push-script is already running" fi </code></pre></li> <li><p>If you want the script to start up after booting up the system you could make a file in /etc/init.d (e.g. /etc.init.d/mypushscript with something like this inside: </p> <pre><code>php /var/www/development_folder/scripts/push2/push.php </code></pre> <p>(You should probably have alot more in this file)</p> <p>You would also need to run the following commands:</p> <pre><code>chmod +x /etc/init.d/mypushscript update-rc.d mypushscript defaults </code></pre> <p>to make the script start at boot-time. I have not tested this so please do more research before making your own init script!</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload