Shutdown script fails to start via Cron job after change

TrueNAS-13.0-U6.2
I have a shutdown script used for over 10 years with no issues and have read that using midclt is better so I changed line 108 on the script. Script works, but now Cron will not start the script, even after reboot. Cron job is set to run the script every 11 minutes.

With midclt changes:
1-Cron will not start script.
2-Manual start of the script via Cron with ‘Run Now’ runs and TN shuts down.
3-Manual start of the script via console runs and TN shuts down.

If I replace the line 108 back to original, Cron will run the script and PC will shut down as normal.

If It runs manually why can’t Cron start it after the change to midclt?

I’ve included the full script. It’s line 100 since I removed my settings.
shutdown.py.txt (5.9 KB)

That must be murder on your uptime. :grinning:

Nothing obvious. You may want to change your log.info line above your changes?

I don’t understand? Every 11 minutes it checks the script for IPs. If no IP address are active TN shutsdown.

Line 107? How do I do that, I just change scripts I don’t actually know anything about writing them. So I wouldn’t know what to put there.

First, on CORE if you want to call the middleware shutdown, you can just use the service command to call the rc.d script which calls the middleware service ix_shutdown stop.

Second, I have absolutely no idea if this would call the system–besides the middleware–to actually shutdown as well (probably doesn’t) but, I see no point in calling anything other than shutdown -p now because the whole point for having the rc.d script is so the system knows how to shut down the middleware–or more accurately: “tell it to cleanup and close shop because the system is shutting down”.

I would have to dig through the code for this “middleware shutdown” thing if I actually wanted to issue a shutdown. I wouldn’t blindly follow a directive like that without researching it a bit more.

Sorry John but I have absolutely and unequivocally no idea what you are talking about, yet alone why Cron won’t start the script after I replace the shutdown -p now with midclt unless I manually start it.

Never assume I know what I’m doing.

Use the same line you’ve used for 10 years. The other line is for SCALE (the middleware call thing makes very little sense on CORE).