Starting phantomJS from a script in a cronjob

后端 未结 3 1058
灰色年华
灰色年华 2020-12-17 21:30

I\'m running a python script through a cronjob. I have a virtual environment and in the cronjob I\'m running it through this virtual environment. When I run the script norma

相关标签:
3条回答
  • As an alternative to accepted answer, you can add the following line at the 1st line of crontab:

    PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs
    

    which specifies the path of PhantomJS before running cron tasks.

    0 讨论(0)
  • 2020-12-17 22:27

    As phantom is probably installed in /usr/local/bin, you should add that dir to PATH in your crontab. The following should do the trick:

    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    
    0 讨论(0)
  • 2020-12-17 22:30

    that did the trick for me:

    #!/bin/bash
    export DISPLAY=:0
    /usr/bin/phantomjs /home/pi/test.js
    
    0 讨论(0)
提交回复
热议问题