i have bash script uses inotifywait upload file moved directory in apache server. in old set up, apache startup on boot; manually open terminal, run script , minimize terminal while runs/monitors indefinitely.
i both apache , script start on bootup can turn on machine, , have process not require further input.
i've tried moving script /etc/init.d , running
sudo chmod +x myscript.sh sudo update-rc.d myscript.sh defaults in order run on boot.
now seems apache not starting on bootup used to. try navigate localhost in firefox , page can't load. after manually starting server, works fine, i'm manually starting server instead of script. , if
pgrep -fl myscript.sh i see instances of script running.
what happening? why script running on boot interfere apache? interaction script has apache monitoring directory creation of new file. none of files changing on bootup?
i noob whole process, have gotten far through extensive googling, can't find should next. thanks
i believe using pre ubuntu 6.10 instructions bootup customization.
you have couple of options. suggestion use rc.local.
from the debian gnu/linux faq:
the rc.local script executed @ end of each multiuser runlevel. in debian configured nothing. provides customisation of boot process, might not sufficient situations.
so need edit /etc/rc.local call myscript.sh , should set.
alternatively, can create upstart compatible service file , enable it.
the ubuntu bootup howto has instructions writing services:
the current reference job/service definition available in man page init, available running man 5 init. there useful pointers in the upstart cookbook.
here example of simple upstart job config: /etc/init/myservice.conf
# myservice - myservice job file description "my service description" author "me <myself@i.com>" # stanzas # # stanzas control when , how process started , stopped # see list of stanzas here: http://upstart.ubuntu.com/wiki/stanzas#respawn # when start service start on runlevel [2345] # when stop service stop on runlevel [016] # automatically restart process if crashed respawn # lets upstart know process detach background expect fork # run before process pre-start script [ -d /var/run/myservice ] || mkdir -p /var/run/myservice echo "put bash code here" end script # start process exec myprocess
Comments
Post a Comment