After some Googling, I learned how to suspend my TrueNAS 25.04.1 using “sudo systemctl suspend” command in the system shell section; and wake the system with my keyboard in the morning.
I also learnt that the Cron Jobs area is where I can schedule a task to that.
It would be great if I can create a Cron Jobs entry to suspend the system at 11:00pm, wake up at 8:00am, daily.
Would anyone kindly show me how to construct it using the GUI?
Thanks in advance.
p.s. I know very little about Linux. If the solution is some sort of script, I would appreciate details how to write it and where in the file system it should reside, etc.
Try:
sudo rtcwake -m mem -s xxxxx
where xxxxxx is the number of seconds after which you want the system to automatically wake up if you haven’t manually woken it before. If you use rtcwake you don’t have to use systemctl suspend.
To set up the cron job, go to System → Advanced Settings → Cron Jobs → Add
then put in the command. Don’t include “sudo” if you select to run as user “root”. Then for the schedule select Custom, then select daily preset and in “hours” change 0 to the hour you want it to suspend, so for 11pm, put in 23.
1 Like
Thank you very much, rockstream.
I created that entry with “rtcwake -m men -s 30” as root and start 2 minuts after I save the cron job. It worked perfectly.
Edit the cron job entry to start at 23:00, every day, week and month; with command “rtcwake -m mem -s 32400” as root. If my calculation is correct, it should wake up tomorrow at 8:00am.
Appreciate it. Time for me to start on Linux for dummy.
I’m going to have to remember this for the next time someone asks how to save power. The option for -m disk looks promising, but I don’t like spinning down drives. Other are fine with it.