3

I have a virtual machine on a cloud host that stays running in non-desktop mode. It has the Cinnamon desktop environment installed, but I don't typically leave the desktop environment open.

I have a cron job I'd like to run every hour which requires opening an app which requires a desktop environment (headful Chrome).

I've been able to schedule the cron job to use the desktop environment by adding the DISPLAY envvar in the job definition:

1 * * * * DISPLAY=:20 /path/to/script/to/execute

However, this only works when I use remote desktop software to open Cinnamon from my laptop.

I'd like to be able to leave the web server running, without having a remote desktop connection permanently open on my end, and run cron jobs that depend on a desktop environment.

Do y'all have a suggestion for running a cron job as I want to? Maybe a way to leave a desktop environment open without using a remote desktop? Or a way to open a desktop environment within a cron job?

Eric Andrew Lewis
  • 1,256
  • 2
  • 13
  • 22

1 Answers1

1

If you don't have a display attached, you'll need to find a headless system that can run with a virtual DISPLAY. Headless Chrome is probably the easiest for you to swap in, and has convenient python bindings [related question].

You might also want to look into running selenium, depending on the task you need to run.

Finally, you might be interested in running a VNC server; depending on the config of your server, you can configure it to stay alive while your client disconnects. usually this is useful for temporary network hiccups, but set to a high enough timeout value, you may get the effects of a persistent, virtual, non-transient display.

j6m8
  • 2,261
  • 2
  • 26
  • 34
  • 1
    Thank you for the suggesion! I was able to set up a persistent virtual non-transient display with TightVNC following this tutorial https://www.techrepublic.com/article/how-to-install-a-vnc-server-on-linux/ – Eric Andrew Lewis Nov 14 '19 at 05:59