Answer the question
In order to leave comments, you need to log in
How to control (stop) a demon?
Found an example of a demon, launched from the console. The question is how to manage it, in particular, stop it? How to restart in case of an error? And how to make it a background so that you can write commands in the console? Thanks to.
#!/bin/bash
while true; do
begin=`date +%s`
php /var/www/html/rules/script.php
end=`date +%s`
if [ $(($end - $begin)) -lt 5 ]; then
sleep $(($begin + 5 - $end))
fi
done
Answer the question
In order to leave comments, you need to log in
1. The daemon must be written in such a way that it does not write to the console, but immediately write to the log file (or have a separate option for debugging to the console).
2. The daemon must be able to process signals for a graceful shutdown (the same -15), or be ready for an incorrect shutdown.
3. The daemon must be able to leave its PID, so that it would be convenient to write a wrapper to it to send signals.
ps signals can be sent via kill
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question