If yhe scripts run from the command line then try to do this… cd into the directory where the script recides then exucute like this… cd /mnt/pool/scripts && ./myscriptname.sh
There was security hardenning which makes it a bit more involved to run a script via cron and I suspect what you are doing.
So I gave it a try, and still did not work.
I thought to keep it simple, and just did the following:
echo “Testing The Shutdown Script” >/var/log/messages
That works no problem, whether it’s a command or added to a script.
Pondering, I realised the reason my containers are not stopping gracefully is because during the shutdown process, docker is no longer available, and hence my commands are not taking affect.
So my question now is, how to gracefully shutdown containers prior to shutting down without having to manually run the scripts…
If I don’t restart them on startup, the STATUS of “docker ps -a” is showing as Exited, and not Stopped, which to me sounds as though they have just had their legs chopped off.
They are set to → “restart: on-failure”.
I have no issues in restarting them, its when the system is rebooted, updated or shutdown that they do not seem to shutdown gracefully.
Perhaps I should just stop them manually via the GUI “select all” function.
So setting the restart policy to “unless stopped” confirms that the container status is definitely in the “Exited” state, and not stopped as they all restarted by themselves when the docker daemon restarted.
I migrated my containers from CentOS thinking I could kill two birds with one stone, but the fact that the data and databases could get corrupted is not a nice way forward.
I will review the situation, and hopefully come up with a solution, or perhaps revert to using Rocky as a replacement for CentOS, but it means having two servers.