[Cialug] cron/bash
Joseph Pietras
joseph.pietras at gmail.com
Thu Oct 21 17:21:57 CDT 2010
When you run it on desktop it should have permissions to change the
desktop. But when as a bash script it might not - and I presume so.
% xhost +
will open your X session so that anyone can run anything on it.
If that works you can change "xhost +" to "xhost +<whatever>", I can't
recall the syntax.
HTH
-joseph
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
>
>
--
-Joseph
cell 858-337-9922
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20101021/be5800ac/attachment.htm
More information about the Cialug
mailing list