for cron you need to do a little scriptCode:
#!/bin/shexport XDG_RUNTIME_DIR="/run/user/$(id -u)"export DISPLAY="$(echo $DISPLAY)"/your/py/script
Really?
For something that requires the desktop without a venv maybe. If the desktop is running and that user is logged in to it. Or if the security settings have been relaxed on whatever desktop is running.
But even then I'm not sure if it would actually work. Under cron $DISPLAY is not set so export DISPLAY="$(echo $DISPLAY)" will do no more than create an empty environment variable called DISPLAY. I also don't see the advantage of using export DISPLAY="$(echo $DISPLAY)" over a simple export DISPLAY. Both achieve the same result whetehr $DISPLAY is set or not.
I've run plenty of non desktop, non interactive python scripts from cron without any of the above.
Statistics: Posted by thagrol — Tue Oct 14, 2025 11:38 pm