1

I want to have a Python program run every minute using crontab, as seen in the picture.

However, it does not work. Why not?

I added an other job which prints the date and user and it works perfectly fine (I have checked it using tail -f /tmp/crontest.text).

My lines:

* * * * * /home/pi/Labb2.py

* * * * * echo "crontest $(date) $(whoami)" >> /tmp/crontest.txt
Paul Ratazzi
  • 6,289
  • 3
  • 38
  • 50
Emelie
  • 109
  • 2
  • 11
  • 1
    Does it work if you say `/usr/bin/python /home/pi/Labb2.py`? That is, place the full path of Python before the script. You can check it with `which python`. – fedorqui May 19 '16 at 08:39
  • Possible duplicate of [Execute python Script on Crontab](http://stackoverflow.com/questions/8727935/execute-python-script-on-crontab) – SiHa Jun 10 '16 at 09:48

1 Answers1

0

You are only specifying a file name, which will make nothing run.

You have 2 options:

1) Add a shebang at the top of your .py file:

#! /usr/bin/env python

2) Explicitly call python on this file.

/usr/local/bin/python /home/pi/Labb2.py

(as a comment said, you can use which python to know the correct path)

As a side note, PEP8 recommend to use all small caps for file names (labb2.py instead of Labb2.py)

DevShark
  • 8,558
  • 9
  • 32
  • 56