Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a Windows 7 machine, having a VM for Ubuntu (image disk: 12.04-desktop-i386.iso).

On the VM I installed Monit 5.3.2, and configured some processes and applications. So I created a script to run my application. This application should display some content on the screen (Im basically displaying two images, using Feh).

The thing is: if I call my script through the command line, it runs ok, and display the images. But if I run through monit, it seems to be running ok, but it doesn't display the images.In the case I try to debug it (remote debug), then I can see the images. So I was supposing this could be some kind of configuration, but didn't find out what (even using the option -I wou'ldn't work).

I"m showing below more details:

-Piece of script on Monit----

check program runMediaHandler with path "/usr/bin/"
 if status == 1 then alert ----

java -jar /home/thais/Desktop/MediaHandler_RC2.jar


1.What works:

  • if I run java directly: java -jar /home/thais/Desktop/MediaHandler_RC2.jar

  • if I run the script directly:

  • if I remote debug putting a breakpoint where the image should be displayed

2.What does not work:

  • putting that piece of information on Monit to "check program", writen above (even if calling monit -I start runMediaHandler)

Thank you in advance,


share|improve this question
Where are you displaying these images? On an X server? – DerfK Jun 29 '12 at 3:05
No, the java program just read a folder, and display its content using the proper program. In such case I'm reading two images and displaying using Feh. – Thaís Jul 1 '12 at 23:32

Without knowing exactly how your program operates, I would guess this is a permissions issue. Monit is starting the script as root rather than as your local user. To see if this is the root of the problem, try modifying your script to run as myuser (change to your local username as appropriate):

su -c "java -jar /home/thais/Desktop/MediaHandler_RC2.jar" myuser
share|improve this answer
Thank you for your time, but actually it didn't work. Anyway, I can run the app as root, so I don't think it's a problem. I'm strongly believing it's related to some foreground/background issue, otherwise why running as remote debug would display the images? – Thaís Jun 29 '12 at 0:35
Notice that even without calling my program, just creating a single script as below: #!/bin/bash /usr/bin/feh /home/thais/Pictures/bondi.jpeg I still don't get the image displayed when running through monit, only if I run the script through the command line. – Thaís Jul 2 '12 at 0:18
Hi Nared133,in the end, your tip proved to be useful, but I had to combine it with some other things to make it work! – Thaís Jul 2 '12 at 5:33

Perhaps monit does not have your Java installation directory in its $PATH.

share|improve this answer
The java installation is not an issue because I can see the program running, it just doesn't display the image, which makes me believe it's something related to background issue. – Thaís Jul 1 '12 at 23:32

According to its webpage, Feh is an X11 application, meaning that it displays on an X server. Generally, X servers have two methods of allowing access to the display: one called XAuth which uses a token file (called .Xauthority) placed in the home directory of the person currently using the display (either by running startx or logging into a display manager like xdm or kdm), and a less secure host-based access control system.

If your program is running as root, then if you set the HOME environment variable to the directory of the user currently logged into the display, your program will read the .Xauthority token from their home directory and be able to display on the screen.

Otherwise, to enable the older host-based authentication, you can run

xhost localhost

in an xterm to allow any program run by any user on the computer to use the display until the display is reset.

share|improve this answer

thank you a lot for your efforts helping me! In the end I tried a few steps that made my program work

1 - not sure if necessary, but I executed the command line (according to monit manual) to make monit run on the foreground:

/usr/bin/monit -Ic /etc/monit/monitrc

2 - I changed my script to set a display and to execute with my user. See how it's now:

export DISPLAY=:0.0
su -c "java -jar /home/thais/Desktop/MediaHandler_RC2.jar" thais
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.