Start Python script with cron

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
cc13
Posts: 3
Joined: Wed Mar 13, 2019 1:31 pm

Start Python script with cron

Post by cc13 »

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:

Code: Select all

/usr/local/sbin/fhem-dht
To start this script hourly with cron I created a file in:

Code: Select all

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

Code: Select all

# 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
User avatar
MichaIng
Site Admin
Posts: 2261
Joined: Sat Nov 18, 2017 6:21 pm

Re: Start Python script with cron

Post by MichaIng »

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

Code: Select all

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