<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr; font-family: Verdana; color: rgb(0, 0, 0); font-size: 13px;">
<div style="">If this bit: "% xhost + \n will open your X session so that anyone can run anything on it." worries you, it should. xhost is an IP level of security... and should be only needed if you are running interactive GUI stuff.<br>
<br>
If you have a permissions error, it's likely a user thing, and you should make sure that your cron job is running under your "chris" user.<br>
<br>
Most likely, though, is that it's an environment problem. That's very common in cron as cron does not load the user environment before it runs things.<br>
<br>
Hey look, as I was writing this, Zach said what I was going to. Compare your environment variables between an active shell and a cron shell (printenv > /tmp/cronenv.txt) and see what's missing.<br>
</div>
<div><br>
<div style="font-family: Tahoma; font-size: 13px;">
<div style="font-family: Tahoma; font-size: 13px;">
<div style="font-family: Tahoma; font-size: 13px;"><font style="font-family: Courier New;" color="#888888" size="1">-Josh More, CISSP, GIAC-GSLC, GIAC-GCIH, RHCE, NCLP<br>
<a href="mailto:morej@alliancetechnologies.net" target="_blank"><span class="il">morej@alliancetechnologies.net</span></a>
<br>
515-245-7701 </font>
<div style="font-family: Tahoma; font-size: 13px;"></div>
</div>
</div>
</div>
</div>
<div style="font-family: Times New Roman; color: rgb(0, 0, 0); font-size: 16px;">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF530548"><font color="#000000" face="Tahoma" size="2"><b>From:</b> cialug-bounces@cialug.org [cialug-bounces@cialug.org] on behalf of Joseph Pietras [joseph.pietras@gmail.com]<br>
<b>Sent:</b> Thursday, October 21, 2010 17:21<br>
<b>To:</b> Central Iowa Linux Users Group<br>
<b>Subject:</b> Re: [Cialug] cron/bash<br>
</font><br>
</div>
<div></div>
<div>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.
<br>
<br>
% xhost + <br>
will open your X session so that anyone can run anything on it.<br>
<br>
If that works you can change "xhost +" to "xhost +<whatever>", I can't recall the syntax.<br>
HTH<br>
-joseph<br>
<br>
<div class="gmail_quote">On Thu, Oct 21, 2010 at 5:16 PM, chris <span dir="ltr"><<a href="mailto:c.rheinherren@gmail.com" target="_blank">c.rheinherren@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font size="2"><font face="verdana,sans-serif">I'm attempting to have a bash script setup to run as a cronjob but it doesnt.<br>
<br>
Here are the details:<br>
</font></font>*/2 * * * * /home/chris/scripts/crotate.sh<br>
<font size="2"><font face="verdana,sans-serif">This is the original bash script, I didn't write it but I like it.<br>
<br>
#!/bin/bash<br>
<br>
#<br>
# Rotates GNOME Wallpaper using pictures in $FOLDER<br>
# Run in background: ./rotate.sh &<br>
# Make sure there are no spaces in picture filenames<br>
# <a href="http://ubuntu.online02.com/node/37" target="_blank">http://ubuntu.online02.com/node/37</a><br>
#<br>
<br>
FOLDER="/home/chris/Pictures/Wallpapers/current" # Change to your directory<br>
cd $FOLDER<br>
<br>
loop () {<br>
NUMBER=$(ls -1 | wc -l)<br>
RAN=$(($RANDOM%$NUMBER+1))<br>
FILE=$(ls -1 | sed -n ${RAN}p)<br>
echo $FILE<br>
gconftool-2 --set "/desktop/gnome/background/picture_filename" --type string "$FOLDER/$FILE"<br>
sleep 90 # Time between change<br>
loop<br>
}<br>
loop<br>
<br>
<br>
-------------------<br>
<br>
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.<br>
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.<br>
<br>
<br>
This is the modified script.<br>
<br>
#!/bin/bash<br>
<br>
FOLDER="/home/chris/Pictures/Wallpapers/current" # Change to your directory<br>
cd $FOLDER<br>
<br>
NUMBER=$(ls -1 | wc -l)<br>
RAN=$(($RANDOM%$NUMBER+1))<br>
FILE=$(ls -1 | sed -n ${RAN}p)<br>
echo $FILE >> /home/chris/scripts/wallpaper.log<br>
/usr/bin/gconftool-2 --set "/desktop/gnome/background/picture_filename" --type string "$FOLDER/$FILE"<br>
<br>
<br>
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.<br>
<br>
<br>
# m h dom mon dow command<br>
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br>
*/2 * * * * /home/chris/scripts/crotate.sh
<div><br>
------------------<br>
<br>
<br>
Any help would be great.<br>
<br>
Just calling the script ./crotate.sh and it works fine.<br>
<br>
Thanks.<br>
<br>
<br>
Chris<br>
</div>
<br>
</font></font><br>
_______________________________________________<br>
Cialug mailing list<br>
<a href="mailto:Cialug@cialug.org" target="_blank">Cialug@cialug.org</a><br>
<a href="http://cialug.org/mailman/listinfo/cialug" target="_blank">http://cialug.org/mailman/listinfo/cialug</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
-Joseph<br>
cell 858-337-9922<br>
</div>
</div>
</div>
</body>
</html>