View previous topic :: View next topic |
Author |
Message |
crowbar n00b
Joined: 03 Jan 2003 Posts: 20
|
Posted: Sun Feb 23, 2003 9:19 pm Post subject: Cron and shell problem |
|
|
I wrote this little script to randomly pick and change the background image in XFCE:
Code: |
#!/bin/bash
number=$(head -1 /dev/urandom | od -N 1 | awk '{ print $2 }')
let "number %= `wc -l /home/bob/.desk_images | awk '{print $1}'`"
sed "$number!d" /home/bob/.desk_images>/home/bob/.xfce/xfbdrc
echo "auto">>/home/bob/.xfce/xfbdrc
xfbd
exit 0
|
It runs fine if run from the command line, but if run as acron job, xbfb (the backdrop manager) doesn't execute (and/or read the rc file).
I've tried adding exec xfbd as well.
The only thing I can think of is that running as a cron job is messing up the user?
Rob |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20054
|
Posted: Sun Feb 23, 2003 9:27 pm Post subject: |
|
|
Have you tried using the full path to xfbd? _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
slartibartfasz Veteran
Joined: 29 Oct 2002 Posts: 1462 Location: Vienna, Austria
|
Posted: Mon Feb 24, 2003 5:00 pm Post subject: |
|
|
check if u specified SHELL in the crontab and keep in mind that as a cronjob your script has not your users shell environment - better always use absolute paths for this... _________________ To an engineer the glass is neither half full, nor half empty - it is just twice as big as it needs to be. |
|
Back to top |
|
|
crowbar n00b
Joined: 03 Jan 2003 Posts: 20
|
Posted: Mon Feb 24, 2003 9:07 pm Post subject: |
|
|
I did try (after posting) using the full path (though it is on the cron path /usr/bin/).
It apparently is a Gtk error:
Quote: |
Gtk-WARNING **: cannot open display:
|
Good thing I get all mail to root sent to a real person |
|
Back to top |
|
|
crowbar n00b
Joined: 03 Jan 2003 Posts: 20
|
Posted: Wed Feb 26, 2003 8:30 pm Post subject: Solution |
|
|
It may not be the most elegant but:
Code: |
#!/bin/bash
number=0
while test "$DISPLAY" != ""
do
while test $number -lt 1
do
#generate a random number
number=$(head -1 /dev/urandom | od -N 1 | awk '{ print $2 }')
#rescale to the number of lines in the file
let "number %= `wc -l /home/bob/.desk_images | awk '{print $1}'`"
done
sed "$number!d" /home/bob/.desk_images>/home/bob/.xfce/xfbdrc
echo "auto">>/home/bob/.xfce/xfbdrc
/usr/bin/xfbd
$number
number=0
sleep 1h
done
exit 0
|
It works |
|
Back to top |
|
|
|