Automatically shutdown at night, automatically boot up in the morning

So I have configured my Thin Client Fujitsu Futro S740 with dietpi - nativePC as a home media server with sonarr/radarr/sabnzbd. Everything has the latest version

It’s probably a super dumb and simple question:

I want to configure dietpi, that it shutdown/sleep mode at a specific time (let’s say 00:00 midnight) and automatically boot back up in the morning at 08.00 am.

I am anyway sleeping at that time and it don’t want the server run during that time.

I use 1gbit lan wired connection. Here is the futro s740 hardware

It’s not a real DietPi question. More related to your system capabilities.

Automatic shutdown is not that difficult and can be done by a crontab entry. For the reboot, you would need to search the web on possibilities.

1 Like

So i Understand that wakeonlan is no option because it’s needs a second pc to send the wake signal?

Bios is also no option because run my thin client headless and have no monitor or keyboard attached. Therefore I cannot reach bios during boot up

So it’s left to rtc clock?

If you want to save power…just get one of those programmable power plug timers[something like that, link is just an example]…just make sure you setup a cronjob to shutdown -h now before the timer cuts power to the box

1 Like

Yes I would do that. But how do I get the server automate boot up in the morning though?

If I remember correctly, thin clients have an option in the BIOS to automatically boot after the power is restored, so it would be useful for you to get to the BIOS somehow. For example, you don’t have a stationary PC that you could temporarily disconnect and connect the Fujitsu?

i will first go down the RTC Clock route and see if thats working. since for that i do not need to change anything with my setup (thin client and cable management is fixed and i would need to break up everything else at my home cinema to get the client out (inkl charging cable etc. - that would be a last resort solution… bad planning on my side. im fully responsible)

i checked now the RTC shutdown and Wake path and it works on my thin client!

I followed this guide and now i have a question for the following step:

  1. you are ready to use this simple shutwake script to shutdown and start up your computer whenever you want:
sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm" 
sh -c "echo `date '+%s' -d '+ 420 minutes'` > /sys/class/rtc/rtc0/wakealarm" 
shutdown -h now
  1. It works like this: make it executable, put it in root’s path (like /usr/local/bin ), and create a root cron job to run it when you want your computer to shut down, like this example that runs the script at five minutes past midnight on weeknights:
# crontab -e 
# m h  dom mon dow   command 
05 00 * * 1-5 /usr/local/sbin/shutwake
  1. The script will set the wakeup alarm at 420 minutes after shutdown at 12:05AM. This is a lot simpler than hassling with UTC and epoch time conversions, which is what you’ll see in other RTC wakeup howtos.


  • in step 2. i need to create a file and make it executable? How do i do that?

It works like this: make it executable, put it in root’s path (like /usr/local/bin )

is that the correct way to do it?:

cd /usr/local/bin
nano shutwake

and then copy paste following:

sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm" 
sh -c "echo `date '+%s' -d '+ 420 minutes'` > /sys/class/rtc/rtc0/wakealarm" 
shutdown -h now

Press Control+x

  • how do i change the cronjob form step 2 and 3 that it runs not weekdays, but everyday. Is this correct?:
# crontab -e 
# m h  dom mon dow   command 
05 00 * * 1-7 /usr/local/sbin/shutwake

maybe a typo, but one time it is in bin and later in sbin:

its says bin and sbin in the guide i linked. i guess its a typo and it should be “bin” in both cases?

shoud the shutwake file have an ending? like shutwake.txt or something like that?

else my procedure is correct?

Normally in bin and sbin are just binaries and no script files. But it doesn’t matther, you can store it wherever you want (and wherever the user has permissions to execute it). But the path in the crontab should correspond to the path where it’s actually stored.
And you don’t need a file type, but you could give it .sh since it’s a bash script.

to make the file executable

chmod +x /usr/local/sbin/shutwake


thanks! do you have a better location in dietpi for the .sh script? or should i use the provided one?

and changing the cronjob to run all days of the week is changed the range from 1-5 (like in the example) to 1-7?
(answered by the link @Joulinar provided. its 1-7)

ok i have created the file and made it excutable as @Joulinar suggested.

but now i have an issue with creating the cronjob. i do the following:

crontab -e 

and my nano editor opens. i want to add

m h  dom mon dow   command 
05 00 * * * /usr/local/bin/

then i want to save the cronjob file with Control+x

confirm with “y”

i get the following

i also tried now

root@DietPi:~# crontab -e -u root
no crontab for root - using an empty one
crontab: installing new crontab
"/tmp/crontab.VMFXJH/crontab":4: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit? (y/n)

beacuse im root user. same error.

pls remove this line

you are sure this is correct name and location of your file?

And did you tried to execute the script manually before adding it to crontab??

root@DietPi:~# cd /usr/local/bin
root@DietPi:/usr/local/bin# ls -la
total 64
drwxr-xr-x  2 root root 4096 Apr  8 15:28 .
drwxr-xr-x 10 root root 4096 Nov 20  2022 ..
-rwxr-xr-x  1 root root  248 Feb  9 16:29 calc-prorate
-rwxr-xr-x  1 root root  221 Feb  9 16:29 chardetect
-rwxr-xr-x  1 root root   74 Dec 17  2022 cheetah
-rwxr-xr-x  1 root root  115 Dec 17  2022 cheetah-analyze
-rwxr-xr-x  1 root root   90 Dec 17  2022 cheetah-compile
-rwxr-xr-x  1 root root  210 Feb  9 16:29 cheroot
-rwxr-xr-x  1 root root  214 Feb  9 16:29 cherryd
-rwxr-xr-x  1 root root  216 Feb 10 11:25 f2py
-rwxr-xr-x  1 root root  215 Feb  9 16:29 guessit
-rwxr-xr-x  1 root root  221 Mar 18 08:16 pip
-rwxr-xr-x  1 root root  221 Mar 18 08:16 pip3
-rwxr-xr-x  1 root root  221 Mar 18 08:16 pip3.9
-rwxr-xr-x  1 root root  155 Apr  8 15:28
-rwxr-xr-x  1 root root  208 Dec 17  2022 wheel


i removed now:

m h dom mon dow command

so the cron looks now only like that:

05 00 * * * /usr/local/sbin/

and now i think it worked:

i will find out tonight at 00:05 o clock i guess :slight_smile:

or is there a way to find out if the cronjob/crontab is now working?

simple set the shutdown time to something close and restart after some minutes.

Got it. Family is using right now the server so I can’t tinker anymore now. Will see what happens tonight and if it doesn’t work I’m gonna try a shorter period tomorrow

the device would cut the power, if set to power up when power is applied, it would autostart
however I guess if there is a software option that would work better…but will the thinclient be using power just sitting idle, it’s not using that much power anyway?

  • Electrical values
  • Power consumption long idle 4.2 W
  • Power consumption sleep mode power 0.59 W (WoL enabled)
  • Power consumption off mode power 0.25 W (WoL disabled)
  • Power consumption note Consumption can differ depending on selected hardware, software and settings.
  • Rated voltage range 100 V - 240 V (AC Input)
  • Rated frequency range 50 Hz - 60 Hz
  • Operating voltage range 100 V - 240 V (AC Input)
  • Operating line frequency range 50 Hz - 60 Hz