masko
masko

Reputation: 35

Selenium with cron

I wrote a small script with python3 and i use there selenium. everything working if I run python command from console but if I want to run it with cronetab script in log has an this error:

Traceback (most recent call last):
  File "/home/tom/Desktop/project/bot.py", line 5, in <module>
    from selenium import webdriver
ModuleNotFoundError: No module named 'selenium' 

selenium is installed with pip3 and in cron tab i have this lines for run my script:

19 * * * * /usr/bin/python3 /home/tom/Desktop/project/bot.py > /tmp/birdz_bot.txt 2>&1

i used only html unit driver, no gui what can I do? THX!

Upvotes: 0

Views: 333

Answers (1)

mark_s
mark_s

Reputation: 496

I've had similar crontab problems like this before that ended up being caused by missing environment variables. crontab doesn't have access to the same environment variables as your console. The answer here recommends something like:

19 * * * * . $HOME/.profile; /usr/bin/python3 /home/tom/Desktop/project/bot.py > /tmp/birdz_bot.txt 2>&1

Upvotes: 2

Related Questions