Start Python script with cron

Hello,

I’m using v6.21.1 on a RPi Zero W and it works well.

For my installed FHEM I created a Python script in:

/usr/local/sbin/fhem-dht

To start this script hourly with cron I created a file in:

/etc/cron.hourly/fhem-dht
-rwxr-xr-x  1 root root  132 Mar 13 13:38 fhem-dht

with the following code:

# read dht11 values every 5mins and feed into fhem
#SHELL=/bin/sh

# m h dom mon dow usercommand
/usr/local/sbin/fhem-dht

In dietpi-cron the value for hourly is set on 17 and I thought that will start this script every hour at the 17. minutes. But nothing happens. I can start both scripts on the console manually with dietpi and root user and it works.

Where is my mistake?

Best,
cc13

I think cron does not identify the file as executable shell script as 1st line is no valid shebang. Please try with:

#!/bin/sh
/usr/local/sbin/fhem-dht