I need to monitor for changes across a folder and its sub-folders and am using Watcher for this purpose. No issues thus far. However, I want to have the Watcher daemon run on reboot. For staters I tried the following.
/etc/init.d
I created the following simple script here
#! /bin/bash
watcher.py start
with watcher.py
located in the /usr/local/bin
folder. I then created a symlink from the /etc/rc2.d
folder ln -s /etc/init.d/watcher /etc/rc2.d/S99watcher
and rebooted.
Checking watcher.py status
reported that it was not running. So I modified my init.d
script as follows
#! /bin/bash
/usr/bin/python /usr/local/bin/watcher.py start
and rebooted. This time watcher.py status
correctly reported Watcher as running.
The immediate problem may be solved but I still do not understand why. Why is it that from an interactive shell prompt I can simply type watcher.py start
to have the Watcher daemon started whilst at bootup I need to explicitly tell Python to run that script?
I generally get my shell & startup scripts working by dint of not giving up rather than any in-depth knowledge of how such things work. I hope that someone here will be able to provide a more informed insight.
$PATH
is not set yet on the moment the script is called, hence the need for absolute paths.s99watcher
symlink is intended to ensure that the script is called after all other serivices, e.g. MySQL, have started. When does $PATH get set? After everything in rc2.d has been run?