How do I get GUI Apps to run from crontab under XFce 4.4.2?

Todd and Margo Chester ToddAndMargo at verizon.net
Fri Oct 24 23:30:59 CEST 2008


Hi All,

I am running XFce 4.4.2 and Virtual Box 2.0.2.  I have
XFce open on the console as user "todd"

I am attempting to shutdown and restart my VM from a bash
script that is run from /etc/crontab. The idea is to suspend
my VM, do a full "dump" of my hard drive, then restart my VM.
The script works fine from the command line, but not from crontab.

When I execute the following from crontab as root to restart
my VM, I get no messages in my debug report:
Code:

       EchoAll "Restarting VirtualXP"
       EchoAll "su todd -c /usr/bin/VBoxManage startvm VirtualXP"
       EchoAll "`su todd -c "/usr/bin/VBoxManage startvm VirtualXP"`"

EchoAll send to several locations, including my debug report.

My debug report (when run from crontab as root):

       Restarting VirtualXP
       su todd -c /usr/bin/VBoxManage startvm VirtualXP


My debug report should be full of stuff from the actual "su -c"
command. And,  executing from the command line as root (not
crontab), it is full of stuff.

After executing from crontab as root, ps gives me:

       # ps ax | grep -i virtual
       24200 ? S 0:00 su todd -c /usr/bin/VBoxManage startvm VirtualXP
       24201 ? Ssl 0:00 /usr/lib/virtualbox/VBoxManage startvm VirtualXP
       24251 ? S 0:00 /usr/lib/virtualbox/VBoxXPCOMIPCD
       24258 ? Sl 0:00 /usr/lib/virtualbox//VBoxSVC --automate
       24266 ? Z 0:00 [VirtualBox] <defunct>


It looks like it is trying to start, but doesn't finish. I think it
is not finding Todd's XFce 4.4.2?

Is there something special I have to do with my script to get GUI
applications to work with crontab?

Many thanks,
-T

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My full restart subroutine:

Code:
RestartVirtualXP () {
    # restart Virtual XP if not running
    VXP="`ps ax | grep -i VirtualXP | grep -v grep`"
    if [ -z "$VXP" ]; then
       EchoAll "Removing Virtual Box tmp directories (some housekeeping)"
       rm -Rf /tmp/.vbox*
       EchoAll ""
       sleep 2

       EchoAll "Restarting VirtualXP"
       EchoAll "su todd  -c /usr/bin/VBoxManage startvm VirtualXP"
       EchoAll "`su todd  -c "/usr/bin/VBoxManage startvm VirtualXP"`"
       EchoAll " "

       VXP="`ps ax | grep -i VirtualXP | grep -v grep`"
       if [ -z "$VXP" ]; then
          EchoAll "WARNING: VirtualXP failed to restart."
          EchoAll " "
       fi

    else
       EchoAll "Minor error: VirtualXP's process is still running."
       EchoAll " "
    fi
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My full debug report (pertaining to this subroutine):

       Removing Virtual Box tmp directories (some housekeeping)
       Restarting VirtualXP
       su todd -c /usr/bin/VBoxManage startvm VirtualXP



More information about the Xfce mailing list