我需要为redis实例运行start-stop-daemon ,并且我希望它发送一个SIGTERM ,如果redis实例不退出,我希望它强制退出。
start-stop-daemonconfiguration表示可以使用--retry选项,但是我想不出办法做到这一点,这是我的当前命令:
/sbin/start-stop-daemon --stop --retry forever/TERM --quiet --oknodo --pidfile /var/run/redis/redis.pid --exec /usr/bin/redis-server
任何提示我将如何能够做到这一点?
有两种方法:
第一个只是指定一个数字--retry值。 然后它将使用/signal/timeout/KILL/timeout时间表。 即发送一个终止信号(用--signal选项指定),然后等待指定的秒数,然后发送一个进程不能忽略的KILL信号,因此它将被强制退出。 该命令将如下所示:
/sbin/start-stop-daemon --stop --signal TERM --retry 5 --quiet --oknodo --pidfile /var/run/redis/redis.pid --exec /usr/bin/redis-server
第二个是指定--retry option的完整时间表 。 它会看起来像:
/sbin/start-stop-daemon --stop --retry TERM/5/KILL/10 --quiet --oknodo --pidfile /var/run/redis/redis.pid --exec /usr/bin/redis-server