1

so I have a script in python that posts tweets to my twitter account. I'm using tweepy.

When I run the script manually with either ./run_my_script.py or python run_my_script.py it works just fine.

I'm trying to run it via cronjob and no matter what interval I use (every minute, every 30 minutes, every 4 hours, etc), I get this same error:

Error Failed to send request: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update_with_media.json?status=information_related_to_my_tweet(Caused by ConnectTimeoutError(, 'Connection to api.twitter.com timed out. (connect timeout=60)'))

Does anyone know how it's possible that I'm receiving this error? I'm only calling

api.update_with_media(media, tweet)

once in the code.

My crontab looks like this

PATH = "my_path_on_my_local_machine"

SHELL = "/bin/bash"

HOME = '/my/home/directory/goes/here"

*/30 * * * * cd the_directory_my_script_is_in && ./run_my_script.py

1 Answers1

2

I'm behind a company proxy. The reason that it worked when I ran the script myself and why it didn't work via cron job is because I didn't source my bash_profile and the connection would not pass through the proxy.

My crontab now looks like

*/30 * * * * cd the_directory_my_script_is_in && source ~/.bash_profile && ./run_my_script.py