I have sphinx_search installed and a pid_file associated with it. When I start the process from the shell, using the command "searchd", then the process gets the PID mentioned in the pid_file. Now, I have written a bash script which checks if process is running, if not start the process using the "searchd" command. But, the process does not get the PID mentioned in the pid_file. Why so?
Why would any process "get a PID" mentioned anywhere ?
Process IDs are assigned by the kernel at the moment a process is forked; nothing else has any influence on what that PID actually is.
Do you have a
pid_file directive in the searchd block of your sphinx configuration file?
Is the shell script disobeying the searchd directive, or are you trying to derive the pid in the shell script?
Also, instead of writing your own shell script to keep sphinx up, you can look at something like
monit or Upstart (on Ubuntu) to do that. It'll be a more "standard" solution, rather than something homebrew.