Run GUI application via cronjob in Ubuntu?

Posted by Christoffer on Server Fault See other posts from Server Fault or by Christoffer
Published on 2010-05-15T16:40:36Z Indexed on 2010/05/15 16:44 UTC
Read the original article Hit count: 271

Filed under:
|
|

Hi,

I have a remote server running "Ubuntu 10.04 Desktop". From it I want to run a script that walks through a list of websites and captures screenshots of them.

The script is working and thoroughly tested.

When I SSH to the server with ssh -X user@ip-adress I can run my script by calling ./myscript.py and everything will work OK.

I then modifed my crontab file and added...
59 17 * * * env DISPLAY=:0 /path/to/myscript.py
...as recommended by the Ubuntu WIKI.

I can see in the /var/log/syslog that my cron job is started, but it doesn't capture any screenshots.

When running env DISPLAY=:0 /path/to/myscript.py from the shell I get
No protocol specified
myscript.py: cannot connect to X server :0

If I ssh to the server without the -X option I only get the second row of the error: myscript.py: cannot connect to X server :0

What can I try now?

More details

  • I have run xhost +local: and checked the output of xhost to see that the option was set correctly.
  • If I run ls /tmp/.X11-unix/ the output is X0
  • The server only has one screen.

Thank you in advance!

© Server Fault or respective owner

Related posts about ubuntu

Related posts about cron