apache - Run bash script after Apache2 restarts on Ubuntu -


i use ubuntu 16.04.

i want add hook invoked once apache2 restarts , runs command line (bash).

for example

php artisan queue:work --queue=high 

ideas?

while not ideal in no way "hook"... write script check status of apache program , toggle "switch" variable.

#!/bin/bash  s=0;  while true;     /etc/init.d/apache2 status > /dev/null;      if [ $? -eq "0" ] && [ ! "${s}" -eq $? ];          # whatever want when apache first starts running.     fi      s=$? done 

so have switch. check return code of status on apache2. 0 appeared when running, not 0 (3) if wasn't running.

$? returns status code of last run command if didn't know.

if [ $? -eq "0" ] && [ ! "${s}" -eq $? ]; if apache running, wasn't running last time checked, started! let's work.

s=$? line sets switch last status code... means next loop $s eq $? loop won't run.

i highly suggest add in sleep 1 or whatever acceptable delay between apache starting , program running is.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -