run crontab with python selenium tor browser display in linux-run crontab with python selenium tor browser in linux-泓源视野


run crontab with python selenium tor browser display in linux

*/5 * * * * /bin/php /home/project/hello.php
5分钟执行一次5minute run

有显示执行任务 run python display
30 5 * * * export DISPLAY=:0; /home/me/

我的电脑任务 my serveur linux
5 8 */1 * * /usr/bin/python3 /root/guo/ >> /root/guo/cron-caiji.log 2>&1

合成任务 is ok
*/5 * * * * export DISPLAY=:0; /usr/bin/python3 /root/ >> /root/tor.log 2>&1

创建脚本 安装python3 -m pip install pyvirtualdisplay

This issue has bugged me for near 6 hours.

So if I write /usr/bin/python3 -u /root/apps/bridge/ in terminal it is working fine.

But it doesn't work for crontab. Right?

Adding for

from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
will not help.

What you need is to make a shell script and write the following - = chmod +x

#!/usr/bin/env bash
export DISPLAY=:0
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
nohup /usr/bin/python3 -u /root/ > /root/tor.log &y

Now run the shell script from Crontab -e

* * * * * /root/

This is what works properly for selenium in crontab without headache in DigitalOcean servers. The paths will be different based on your server and program location.

share improve this answer follow

本文由 泓源视野 作者:admin 发表,其版权均为 泓源视野 所有,文章内容系作者个人观点,不代表 泓源视野 对观点赞同或支持。如需转载,请注明文章来源。


Protected with IP Blacklist CloudIP Blacklist Cloud
您是第8237545位访客, 您的IP是:[]