I have a python script main.py
, which reads my latest tweet using tweepy.
I created a shell script looplauncher.sh, which call this python script:
cd /
cd home/pi/LCDinterface
sudo python main.py &
cd /
If I run python main.py
or sh looplauncher.sh
with or without sudo, my program runs fine. I pasted this line into cron: using sudo crontab -e
*/2 * * * * sleep 60 && sudo sh /home/pi/LCDinterface/looplauncher.sh >/home/pi/logs/loopcronlog 2>&1
The python script really does run at every 2 minutes ( I see it from the logs). But I can never get my tweet, If I run main.py manually I always get my tweet. I tried a lot of combination of sudo/ no sudo, added delay to give time for the connection. But nothing works so far. Can you help me with that? (I am doing this on a Raspberry Pi 3)
I got errors like this , when cron runs:
Traceback (most recent call last):
File "main.py", line 49, in <module>
main()
File "main.py", line 32, in main
tweet = getTweet('RaspProject')
File "/home/pi/LCDinterface/twitterHelper.py", line 20, in getTweet
print (tweet._json['text'])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 32: ordinal not in range(128)
Running manually the scripts works fine. (Although I do really have some special hungarian letters in there, like éáőóű