Cron job: how to run a script that requires to open display?

后端 未结 2 1478
眼角桃花
眼角桃花 2020-12-11 05:14

I want to set up a cron job to run a python script, but it gives me this error:

RuntimeError: could not open display

This is because I imp

2条回答
  •  情话喂你
    2020-12-11 05:35

    You could also run your application in a framebuffer using xvfb or a similar tool:

    or sudo apt-get install xvfb

    Usage:

    xvfb :1 -screen 0 800x600x8 & # WIDTHxHEIGHTxCOLORDEPTH
    export DISPLAY=":1"
    java application_name.jar 
    

    or shorter:

    xvfb-run -a -e /tmp/some/log/file.log /home/user/application.run
    

    -a chooses a display number automatically, -e file specifies a logfile for error messages.

提交回复
热议问题