[Cialug] cron/bash
Don Ellis
don.ellis at gmail.com
Thu Oct 21 17:23:02 CDT 2010
I think it's setting a background image in a background environment.
Wouldn't be visible to a logged in user. Need to have it attached to a
session of some kind for you to actually be able to see something, maybe in
your .profile, with a test for whether it's already running. I'm not sure
what kind of .profile-like action takes place when your X session starts,
but that's where it probably needs to be.
--Don Ellis
On Thu, Oct 21, 2010 at 5:16 PM, chris <c.rheinherren at gmail.com> wrote:
> I'm attempting to have a bash script setup to run as a cronjob but it
> doesnt.
>
> Here are the details:
> */2 * * * * /home/chris/scripts/crotate.sh
> This is the original bash script, I didn't write it but I like it.
>
> #!/bin/bash
>
> #
> # Rotates GNOME Wallpaper using pictures in $FOLDER
> # Run in background: ./rotate.sh &
> # Make sure there are no spaces in picture filenames
> # http://ubuntu.online02.com/node/37
> #
>
> FOLDER="/home/chris/Pictures/Wallpapers/current" # Change to your directory
> cd $FOLDER
>
> loop () {
> NUMBER=$(ls -1 | wc -l)
> RAN=$(($RANDOM%$NUMBER+1))
> FILE=$(ls -1 | sed -n ${RAN}p)
> echo $FILE
> gconftool-2 --set "/desktop/gnome/background/picture_filename" --type
> string "$FOLDER/$FILE"
> sleep 90 # Time between change
> loop
> }
> loop
>
>
> -------------------
>
> it works fine if you just run it or put it in screen and run it so you can
> detach and close out of it while it runs.
> So I wanted to run this without having a screen or open terminal session
> going so I removed the loop notes and setup a cron job for it.
>
>
> This is the modified script.
>
> #!/bin/bash
>
> FOLDER="/home/chris/Pictures/Wallpapers/current" # Change to your directory
> cd $FOLDER
>
> NUMBER=$(ls -1 | wc -l)
> RAN=$(($RANDOM%$NUMBER+1))
> FILE=$(ls -1 | sed -n ${RAN}p)
> echo $FILE >> /home/chris/scripts/wallpaper.log
> /usr/bin/gconftool-2 --set "/desktop/gnome/background/picture_filename"
> --type string "$FOLDER/$FILE"
>
>
> It does write to my log file that i created. Just fine with the name of the
> image that should be the desktop image but there is no change to the
> desktop.
>
>
> # m h dom mon dow command
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> */2 * * * * /home/chris/scripts/crotate.sh
>
> ------------------
>
>
> Any help would be great.
>
> Just calling the script ./crotate.sh and it works fine.
>
> Thanks.
>
>
> Chris
>
>
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20101021/859ef0a6/attachment.htm
More information about the Cialug
mailing list