The startup scripts on most Linux distributions handle this, by saving the Process ID of the service (daemon) when they launch it.
These PIDs are typically stored in /var/run/. For example on my system Apache2 stores it original or parent process ID (useful for pre-forked processes) in /var/run/apache2.pid. So you can then send signals such as SIGHUP or SIGSTOP to the process to signal either a configuration reload or to stop the service (daemon).
One note to help with your ps ax style process searching is to use a little trick to escape the grep's regular expression pattern used for matching, such that it doesn't match itself. E.g. ps ax | grep [a]pache2 | wc -l
man test gives you the basics of the test command. The best is basic shell scripting, which is dependant on which shell you are using. Normally for basic scripting, writing scripts for the Borne Shell (/bin/sh) is recommended.
#!/bin/sh
RC= `ps ax | grep [a]pache2 | wc -l`
if [ $RC -gt 0 ]; then
kill -SIGSTOP `cat /var/run/apache2.pid`
fi