I would like to run a script (
/var/www/client.php) whenever a Raspberry Pi boots:
I believe my two options are to put
/usr/bin/php /var/www/client.php & in
/etc/rc.local or do something like the following:
Code:
sudo vi /etc/init.d/client
sudo chmod 755 /etc/init.d/client
sudo update-rc.d client defaults
Code:
michael@raspberrypi:~ $ cat /etc/init.d/client
#!/bin/bash
# /etc/init.d/client
### BEGIN INIT INFO
# Provides: client
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: bla bla bla
# Description: Start PHP client script to ask for changes from remote AJAX queries
### END INIT INFO
# /usr/bin/php /var/www/client.php &
michael@raspberrypi:~ $
I've tested both of them, and they both work. Is this correct, or should it be done differently? Is one way more appropriate/professional than another?
Next, instead of directly executing the PHP command, I would like to something like the following. As I am typing this, I expect this is why I would want to use the second option and not
/etc/rc.local, right? Note that I am a not positive about the
/etc/init.d/client script.
Code:
sudo /etc/init.d/client start|stop|status