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

Erik Harrison erikharrison at gmail.com
Fri Oct 24 23:39:47 CEST 2008


On Fri, Oct 24, 2008 at 5:30 PM, Todd and Margo Chester
<ToddAndMargo at verizon.net> wrote:
> 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?

I dunno anything about Virtual Box, but I would guess it can't connect
to X because it doesn't know the display. If Virtual Box supports
something like --display you could use that, or just manually set
$DISPLAY in your shell script.

>
> 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
> _______________________________________________
> Xfce mailing list
> Xfce at xfce.org
> http://foo-projects.org/mailman/listinfo/xfce
> http://www.xfce.org
>



-- 
Erik
"It's true, Alice Cooper is a hippie, but he's the bad kind of hippie.
He's the kind of hippie that breaks into people's offices, beats them
up, and shoots them in the head. Why? To steal their antique chairs."



More information about the Xfce mailing list