Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, can anybody tell me if it is possible to configure a cronjob from root level so that it uses GTK applications (like gxmessage in my case) to give out notifications on the screen?
On my Debian machine the user can evoke these notifications from the script executed by his crontab but the same script executed from root's crontab doesn't bring up these messages. The scripts works, though, just the gxmessage part won't work.
I need the root permissions because the script is meant to be a system admin job with a final shutdown command in case the battery runs low.
I suspect that the script doesn't work because root in some cases is not "allowed" to run graphical apps for security reasons. Is that the case here?
Last edited by XavierP; 09-03-2009 at 05:11 PM.
Reason: Moved over to Software
but the same script executed from root's crontab doesn't bring up these messages. The scripts works, though, just the gxmessage part won't work.
By default cronjobs will report errors to a preconfigured (MAILTO) or default (crontab owner) email address. Looking for clues in returned messages might give a clue. Common pitfalls are a missing DISPLAY variable or Xauth auth.
I actually can execute the script as root and it then also pops up the gxmessage notification. I tried defining the DISPLAY variable in the script as well as in the crontab. The same with the Xauthority variable.
I think I checked out all possible combinations. No results.
Note that the only thing which doesn't work is executing gxmessage from the crontab as root. It works as user, and it works as root from the command line. It really puzzles me, what is the difference between executing a script from the CL or from the crontab apart from the Display and xauthority?
About the error reports: I saw that there is no mail for root, I never configured it but I thought it would work automatically. The user gets mail, though. With Debian, by default, do I have to configure the mail system for root in order to have it working? Seems strange to me ...
That is a root crontab entry. With that the notification gets launched, but, of course, the shutdown command will
fail. I am kind of abusing my user for the gxmessage notification. If I change "myuser" for "root" again it doesn't work.
Btw, the scripts has the correct permissions set, it is using the commands with full path.
Ok, after another night fiddling around I found what was the problem.
It was actually the Xauthority as UnSpawn suggested. I tried that before already but apparently I did something wrong.
Anyway, it looks like the issue with gtk and root cronjobs is that root can't effectuate graphical notifications because it has no Xauthority file in /root. Hence X will negate access here. I guess cronjobs run in a very different environment than root from the CL. Otherwise I can't explain why the same scripts works from the CL and not from the crontab.
Nevermind, the solution here was using the Xauthority from the normal user by exporting it just before issuing the gxmessage command.
Hope that will be a help for someone having a similar problem one day.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.