I wrote a python script that logs some data to a txt file with the absolute path /home/pi/foo.txt through button presses that trigger interrupts. I've started the script many times through the command line without any problems: when you press go, it goes, and when you press stop, it stops. The script is located in /home/pi/log.py. I wrote a shell script that will execute this python script because I read that it may help on a tutorial, so let's call it log.sh which calls
#! /bin/sh
cd /home/pi
/usr/bin/python /home/pi/log.py
However, when I attempt to start this script through crontab by adding it to my
@reboot log.sh
the script will run, but no button presses will stop the script (aka stop button won't work). The cpu usage goes up to 100% and sticks there. I've tried copying and pasting the environment variables from my user environment into crontab, but that won't work either.
Any ideas?
printstatements in your code might help. Where did you add thecronentry (@reboot log.sh)? If it's getting run asroot, have you tried manually running your script asroot(or are you doing that already)?