You are not logged in.
Pages: 1
I tried the following script from the feh wiki page to change my wallpaper:
#!/bin/sh
WALLPAPERS="/mnt/path/to/wallpapers"
ALIST=( `ls -w1 $WALLPAPERS` )
RANGE=${#ALIST[*]}
SHOW=$(( $RANDOM % $RANGE ))
feh --bg-scale $WALLPAPERS/${ALIST[$SHOW]}
Here's the cron job (trying to run it every two minutes)
*/2 * * * * /usr/local/bin/wallpaper.sh
Why doesn't it work from cron? If I run the script from the command line, it works fine.
Any ideas?
Thanks, Scott
Last edited by firecat53 (2008-09-04 00:10:44)
Offline
I don't think cron can run something every two minutes. Only 1minute, 1hour, and 1 day intervals along with its other features, if I am not mistaken.
Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.
Offline
the other problem is cron runs as root and it can't access your display try su your username in the script
Last edited by genisis300 (2008-09-03 21:44:30)
"is adult entertainment killing our children or is killing our children entertaining adults?" Marilyn Manson
Offline
You can actually run cron every two minutes, and you cron command seems to be fine. I believe your issue has more to do with what genesis300 has pointed out.
Have you Syued today?
Free music for free people! | Earthlings
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery
Offline
Ok, I changed the script with su, but it's still not working. As an idiot check, I looked, and the cron deamon is indeed running
If I try to run the script from the command line now, it asks me for my user password . . . and I'm already running as that user.
I tried a test cron :
*/1 * * * * /bin/date >> /home/firecat53/date.txt
And it worked fine. The permissions on date.txt were firecat53:users 644. So doesn't that mean that that cronjob is executed as me? If I edited crontab like
sudo crontab -e
then I think it would create a job as the root user.
Could this have something to do with somehow needing to recognize a running X session, since feh is an X application?
#!/bin/sh
WALLPAPERS="/mnt/ubuntu-home/firecat53/docs/wallpapers"
ALIST=( `ls -w1 $WALLPAPERS` )
RANGE=${#ALIST[*]}
SHOW=$(( $RANDOM % $RANGE ))
su -c 'feh --bg-scale $WALLPAPERS/${ALIST[$SHOW]}' firecat53
I'm afraid I'm still stumped!
Thanks!
Scott
Last edited by firecat53 (2008-09-03 22:40:35)
Offline
Open up an xterm and run 'env | grep -i display'. The output will probably be :0.0. Add it to your shell script like so:
DISPLAY=:0.0 feh --bg-scale $WALLPAPERS/${ALIST[$SHOW]}
There should be no need use sudo while creating the crontab or while in the script.
Offline
Yep, I just found the DISPLAY=:0.0 trick just before you posted, nj So I took out the su from the script and it works perfectly with the cronjob as follows:
*/2 * * * * DISPLAY=:0.0 /usr/local/bin/wallpaper.sh
Thanks, all!
Scott
Offline
Pages: 1