# Daily automatic scheduled shutdown / Cronjob working only once

**URL:** <https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598>\
**Category:** Troubleshooting\
**Created:** [7 December 2023 07:41 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598 "2023-12-07T07:41:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maginos](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@Maginos](https://dietpi.com/forum/u/Maginos)\
**Post date:** [7 December 2023 07:41 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/1 "2023-12-07T07:41:45Z")

</div>

### Creating a bug report/issue

I have searched the existing open and closed issues

#### Required Information

- DietPi version | 8.24.1
- Distro version | bookworm
- Kernel version | 6.1.0-13-amd64
- Architecture | amd64
- SBC model | Intel Nuc

#### Additional Information (if applicable)

- Software title | crontab / shutdown
- Was the software title installed freshly or updated/migrated? freshly installed
- Can this issue be replicated on a fresh installation of DietPi? Yes

#### Steps to reproduce

1. sudo crontab -e
2. add: 30 22 \* \* \* /usr/sbin/shutdown -h 0  
or 30 22 \* \* \* bash /root/shutdown.sh  
or 30 22 \* \* \* /bin/bash /root/shutdown.sh

Content of /root/shutdown.sh:

#!/bin/bash

/usr/sbin/shutdown -h 0

#### Expected behaviour

- PC should shutdown every day at 22:30.

#### Actual behaviour

- On the first day after the crontab was changed, the cronjob works normally. On the following days, the PC doesn’t shut down.
- After manual execution of the /root/shutdown.sh script, DietPi shuts down normally.

#### Extra details

- Dietpi starts with LXDE Desktop
- In crontab of root user this line was added: @reboot startx
- After the boot process has finished, the software feh starts a Slideshow on the connected monitor

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [7 December 2023 07:58 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/2 "2023-12-07T07:58:36Z")

</div>

did you already checked system log on the day `cron` was not executed?

```auto
journalctl -u cron

```

---

<div class="post-metadata">

**Author:** ![Maginos](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@Maginos](https://dietpi.com/forum/u/Maginos)\
**Post date:** [7 December 2023 08:14 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/3 "2023-12-07T08:14:30Z")

</div>

Actually no. I can check this in the evening.

Here are the first lines of the logs right now:

```auto
Dec 07 08:42:27 Collin systemd[1]: Started cron.service - Regular background program processing daemon.
Dec 07 08:42:27 Collin cron[527]: (CRON) INFO (pidfile fd = 3)
Dec 07 08:42:27 Collin cron[527]: (CRON) INFO (Running @reboot jobs)
Dec 07 08:42:27 Collin CRON[529]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Dec 07 08:42:27 Collin CRON[534]: (root) CMD (startx)
Dec 07 08:45:01 Collin CRON[1195]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Dec 07 08:45:01 Collin CRON[1196]: (root) CMD (bash /root/heif-convert.sh)
Dec 07 08:45:01 Collin CRON[1195]: (CRON) info (No MTA installed, discarding output)
Dec 07 08:45:01 Collin CRON[1195]: pam_unix(cron:session): session closed for user root

```

Entries 6-9 repeat every five minutes. This is because the script /root/heif-convert.sh is executed every five minutes, so this would make sense.

Actually I don’t know, why the cron.service is started at 8:42, when the Nuc starts at 7:30 via wake on lan. Date and time are correct (checked via “date” command).

The entries above are the first ones in the log, so adding “-n 100” to the journalctl command does not show more / earlier entries.

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [7 December 2023 08:44 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/4 "2023-12-07T08:44:01Z")

</div>

you could check whole log running `journalctl` to see what happen around 8:42

---

<div class="post-metadata">

**Author:** ![Maginos](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@Maginos](https://dietpi.com/forum/u/Maginos)\
**Post date:** [7 December 2023 08:52 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/5 "2023-12-07T08:52:21Z")

</div>

Ok there I tested a small change to the /root/shutdown.sh script. So the time stamp seems reasonable.

But the problem with the non-working cronjob at 22:30 persists.

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [7 December 2023 20:29 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/6 "2023-12-07T20:29:58Z")

</div>

> [@Maginos](#):
>
> But the problem with the non-working cronjob at 22:30 persists.

just check log once `cron` has not triggered the shutdown

---

<div class="post-metadata">

**Author:** ![Maginos](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@Maginos](https://dietpi.com/forum/u/Maginos)\
**Post date:** [8 December 2023 21:51 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/7 "2023-12-08T21:51:11Z")

</div>

So this is the actual crontab:

\*/5 \* \* \* \* bash /root/heif-convert.sh  
30 22 \* \* \* /usr/sbin/shutdown -h 0  
@reboot startx

In the logs I can see, that the Nuc restarted at 22:30 instead of shutting down. Do you have any idea, why the nuc restarts instead of staying off? Do you think wake on lan might be a problem?

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [9 December 2023 11:35 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/8 "2023-12-09T11:35:56Z")

</div>

You could try power off instead of shutdown command. But maybe there is a client within the network who forced the reboot.

---

<div class="post-metadata">

**Author:** ![Maginos](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@Maginos](https://dietpi.com/forum/u/Maginos)\
**Post date:** [9 December 2023 12:11 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/9 "2023-12-09T12:11:45Z")

</div>

I also tried the /usr/sbin/poweroff command, but that didn’t work either.

I have a proxmox host in the same network, but this sends only one magic package at 7:30. But I will search for other hosts.

---

<div class="post-metadata">

**Author:** ![Maginos](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@Maginos](https://dietpi.com/forum/u/Maginos)\
**Post date:** [12 December 2023 06:24 UTC](https://dietpi.com/forum/t/daily-automatic-scheduled-shutdown-cronjob-working-only-once/18598/10 "2023-12-12T06:24:37Z")

</div>

Ok, so I found the problem.

In the BIOS I had activated, that the Nuc should start at 7:30 am. Since this did not work, I switched to the WOL solution. When I switched off the BIOS setting, the Nuc shuts down perfectly at 22:30 and stays off.
