How to schedule a shutdown of the system?

flashdrive

Patron
Joined
Apr 2, 2021
Messages
264
Hi,

as asked here:

Is there another option to shut down the system automatically?

 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
If not cron, what trigger would you think of using to decide it's time to shut down?

If you're comfortable using a cron task, then have it call the middleware:

midclt call system.shutdown
 

flashdrive

Patron
Joined
Apr 2, 2021
Messages
264
Hello @sretalla

I am curious why TN Scale = Debian seems to behave different compared to TN Core = FreeBSD in that cron job:

TN Core works as intented
TN Scale I could not get to work

I will try "midclt call system.shutdown"
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
It's also cleaner to have the middleware tidy up before the shutdown on CORE too, so if it works on SCALE, I suggest adopting the same approach on CORE.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
You may also find that the reason it doesn't work the same on SCALE is a path problem... in which case the middleware command also won't work.

using:

/usr/bin/midclt call system.shutdown

should remedy that.
 

flashdrive

Patron
Joined
Apr 2, 2021
Messages
264
It's also cleaner to have the middleware tidy up before the shutdown on CORE too, so if it works on SCALE, I suggest adopting the same approach on CORE.
You may also find that the reason it doesn't work the same on SCALE is a path problem... in which case the middleware command also won't work.

using:

/usr/bin/midclt call system.shutdown

should remedy that.

Check, I will report back
 

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
Another way is:

/usr/bin/cli -c 'system shutdown'
 

flashdrive

Patron
Joined
Apr 2, 2021
Messages
264
@sretalla

/usr/bin/midclt call system.shutdown

edit:
---
I have tried as well, no luck:

su /usr/bin/midclt call system.shutdown
sudo /usr/bin/midclt call system.shutdown
---

did NOT work in cron job UI - user "root"

did work when executed manually via the play button (system halted, powered off)

Are there any logs to be checked for cron?
 
Last edited:

flashdrive

Patron
Joined
Apr 2, 2021
Messages
264
for testing I have upgraded to Cobia Beta 1

su /usr/bin/midclt call system.shutdown

did work - I have not changed anything.

So might this be a bug then?



I did forget to mention that my system in
  • TrueNAS-SCALE-22.12.3.3
does have a time issue, which works fine in Cobia Beta 1 - the cronjob was however executed as per WebGui in
  • TrueNAS-SCALE-22.12.3.3

After changing the boot environment back to 22.12.3.3 the time is now correct, I will try the cron job again.
 
Last edited:

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
Did you try my command?
 

flashdrive

Patron
Joined
Apr 2, 2021
Messages
264

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
There is a log if you can catch it in time. Right after it runs from cron, go to jobs then history (top right of screen). On my system IPMI spams this screen so I don't have much history, but cron jobs show up there after they are done. You should be able to expand and even find the log file for the cron job. From memory as I currently have no cron jobs in the last 30 that are showing up there, it's all IPMI spam.
 

idtechno

Cadet
Joined
Sep 25, 2023
Messages
2
Hello, I have the same problem, I created a cron job to close at the scheduled time but it is not working. When I run it manually, by pressing the play button, it works. Have you solved it? I tried many commands and nothing.

MicrosoftTeams-image (3).png


MicrosoftTeams-image (1).png
 

thomas.bst

Cadet
Joined
Oct 13, 2023
Messages
1
Hi everyone,

I solved this problem by setting my BIOS clock to UTC (instead of my local timezone) and configured a post-init command (systemctl restart cron) to restart the cron service after the system startup. After making these adjustments, my cron job to shut down my NAS works perfectly. Below are my job settings:

Capture d'écran 2023-10-13 231148.png

OS Version: TrueNAS-SCALE-22.12.4



Thomas
 

HoneyBadger

actually does care
Administrator
Moderator
iXsystems
Joined
Feb 6, 2014
Messages
5,112
Hi @thomas.bst

BIOS or "hardware time" should always be set to UTC when using TrueNAS, and then a local time zone adjusted as necessary.

The command to shut down should be midclt call system.shutdown as shown by others in the thread - I've just tested it out on my SCALE machine and it does shut the system down properly.
 
Top