[PLUG] SOLVED Make cron send an e-mail upon completion

Ben Koenig techkoenig at gmail.com
Tue Jan 28 06:40:09 UTC 2020


On Mon, Jan 27, 2020 at 7:41 PM John Jason Jordan <johnxj at gmx.com> wrote:

> On Mon, 27 Jan 2020 20:54:11 -0500
> Tomas Kuchta <tomas.kuchta.lists at gmail.com> dijo:
>
> >This, opening a dialog box, may not work unless you are logged in in a
> >GUI desktop.
> >
> >Just curious - will this work as written when that command is issue by
> >Cron by root?
> >
> >I would have thought that it wouldn't, thought I have not tried.
>
> I will know tomorrow morning. :)
>
> Oh wait, it won't. I had been running the script over and over today to
> set up the message window, but I had been running it as me (jjj). Just
> now I tried it with sudo and the message failed:
>
> No protocol specified
> Unable to init server: Could not connect: Connection refused
> gxmessage: unable to initialize GTK
>

Use the $DISPLAY variable to launch on a target X server. Since you on a
desktop system you probably only have X running once, so try something like
this
DISPLAY=:0 gxmessage <args go here>

you can echo $DISPLAY to find out what display is currently running.
Setting the env variable before any graphical command can be used to
specify which x server/screen you want it to be displayed on. cron jobs run
outside of X, so $DISPLAY is usually unset.

>
> (Sigh.)
>
> Gxmessage is the same as xmessage, except that it has some extra
> features and runs on GTK. Maybe I can repair this by switching to
> xmessage. I'll try that later.
> _______________________________________________
> PLUG mailing list
> PLUG at pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>



More information about the PLUG mailing list