why you dont try to use systemd to manage daemons, its easier and available since debian Jessie. /etc/systemd/system/servicemysql.service
[Unit] Description=MySQL task DefaultDependencies=no Conflicts=reboot.target Before=poweroff.target halt.target shutdown.target Requires=poweroff.target [Service] Type=oneshot ExecStart=/path/to/your/script.sh ExecReload=/usr/bin/kill -HUP <your pid of MySQL> $MAINPID RemainAfterExit=yes [Install] WantedBy=shutdown.target Dont forget to give 0644 permissions to this file and after every modification run:
systemctl daemon-reload then to enable the daemon run:
systemctl enable <name of the service> and to start it run:
systemctl start <name of the service> For checking if the service is running execute:
systemctl status <name of the service>