Windows & Linux

Not The Answer You Should Be Looking For? Browse Other Questions Called Ubuntu Cron Or Ask Your Own Question.


First of all, for this important fact, sudo crontab -e should not be used as this will change Crontab to run as root. In it, you need to run your personal crontab user so that the gnome that stores the session is yours. Release sudo and hurry crontab -e. Add yourself a file to cron.allow if necessary to allow the public to have a trusted crontab file as a user. (Also keep changing New to root crontab and delete the entry.)

Secondly, you can’t run gnome-like utilities with cron by properly hooking them up to each of our $DISPLAY variables. Wednesday,which experts say cron offers to young people is not as full-featured as a login shell, for example, and it doesn’t run your internal Go graphical environment, it’s not tied to it. Note the following: It is entirely possible for more than one graphical condition to be met. How does an illegal system program know which one you want if you want? it doesn’t work. The customer must know what DISPLAY it is on and simply run the pass to order it.

How do I stop the cron daemon?

After all, this doesn’t seem like the right place for this. Um, why on earth would you want to get rid of a session on a regular basis? All that the user does at the moment is the choice of atomization. also knows if the user is logged in or not, so it can be available all the time.

answered August 23, 2011 at 8:35 am




As Pavel Selivanov points out in this article, it’s important to set DBUS_SESSION_BUS_ADDRESS and DISPLAY to enable GUI related tasks for some cron jobs.

It has a written wrapper that gets DBUS_SESSION_BUS_ADDRESS for Gnome, xfce, Unity, and KDE cinnamon. I can confirm that it works in ubuntu:16.04.

[ "$#" -lt 1 ] && mirror "Usage: program options $0" && leave 1


env_reference_process=$( "$user" pgrep -u xfce4-session || "$user" pgrep Cinnamon-session -u || "$user" pgrep -u gnome-session || "$user" pgrep -u gnome-shell || "$user" pgrep -u kdeinit )

export DBUS_SESSION_BUS_ADDRESS=$(cat /proc/"$env_reference_process"/environ | grep -z ^DBUS_SESSION_BUS_ADDRESS= | zed 's/DBUS_SESSION_BUS_ADDRESS=//')
export DISPLAY=$(cat /proc/"$env_reference_process"/environ | grep -z ^DISPLAY= | sed 's/DISPLAY=//')
"$Program" To "$@"

A custom cron job will then likely be created, which on a specific schedule usually has the crontab syntax. Here, for example, every 15 minutes from 22:00 to 5:59:

*/15 22-23.00-05 1 . * * gui-cron gnome-session-quit --power-off

How do I set up a cron job?

replied June 21, 2017 at 1:35 pm.