Shutdown Delay (to allow shutdown scripts to execute)

Scharbag

Guru
Joined
Feb 1, 2012
Messages
620
I have a shutdown script that runs on shutdown. It causes all my ESXi VMs that rely on TrueNAS to shutdown. Problem is that they usually take longer to shutdown than TrueNAS, so the iSCSI share goes away before all the VMs are properly shutdown.

Is there a simple way to pause the shutdown? This would also help when the UPS shutdown happens too. Just need 60 seconds or so.

Thanks for the help, sorry if it is an easy setting (but I cannot find it).

Cheers,
 
Joined
Oct 22, 2019
Messages
3,641
Perhaps under the Tasks -> Init/Shutdown Scripts, you can add a shutdown script that simply runs the command:
Code:
sleep 60

Not sure when exactly these scripts are executed, but I'd assume they'd execute before unmounting any datasets or stopping any services.
 

Scharbag

Guru
Joined
Feb 1, 2012
Messages
620
Perhaps under the Tasks -> Init/Shutdown Scripts, you can add a shutdown script that simply runs the command:
Code:
sleep 60

Not sure when exactly these scripts are executed, but I'd assume they'd execute before unmounting any datasets or stopping any services.
I tried putting a sleep command in my shutdown script but it seems to get ignored as I am initiating a shutdown from the GUI.

Thanks for the suggestion though.

Cheers,
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
For the UPS shutdown, you may find this thread helpful.

 

Scharbag

Guru
Joined
Feb 1, 2012
Messages
620
For the UPS shutdown, you may find this thread helpful.

Yeah, saw that, But I do not need this just for UPS. More for regular maintenance - not a need, just lazy and would rather rely on my script to gracefully shit stuff off instead of digging into ESXi...

Thank you though!
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
For the regular shutdowns, use the API call, which includes a delay parameter:

midclt call system.shutdown <delay in seconds>
 

Scharbag

Guru
Joined
Feb 1, 2012
Messages
620
For the regular shutdowns, use the API call, which includes a delay parameter:

midclt call system.shutdown <delay in seconds>
Sorry for the n00b question, but is that a CLI command then? I guess that would work. Would be nice if you could just set a shutdown delay parameter in the GUI...
 
Joined
Jun 15, 2022
Messages
674
I think really a delayed shutdown is leading the horse by it's tail.

The proper way to do this is via a script that shuts down each VM, and when that VM and the other VMs are truely down the script calls the TrueNAS shutdown.

To do it the other-way-round assumes timing conditions today will be relevant every tomorrow.
 
Top