[PLUG] Resolved: cron problem

Richard C. Steffens rsteff at comcast.net
Fri Oct 26 02:02:25 UTC 2007


Robert Citek wrote:
> On 10/25/07, Richard C. Steffens <rsteff at comcast.net> wrote:
>> Recommendations?
> 
> Run this script:
> 
> true ; (
> crontab -l > crontab.bak
> echo "* * * * * date > /tmp/date.txt" > crontab.new
> crontab crontab.new
> crontab -l
> 
> echo -n > /tmp/date.txt
> watch -n 1 'date ; cat /tmp/date.txt'
> )
> 
> Initially, you should see just the output from the date command.  Then
> at the top of the minute, you should see the output of the date
> command above the output of the date.txt file.  Also the output of the
> date.txt should change every minute. Do you see that?
> 
> If you do, then your crond deamon is working.  you can restore you
> original crontab with this command:  crontab crontab.bak

That script ran as promised.

> If you don't, then as root restart your crond deamon with
> /etc/init.d/crond restart
> 
> Also, you can rewrite those last two lines like so:
> 
> 1-59/5 * * * * /home/rsteff/ShellScripts/x10-lights-on.sh
> 3-59/5 * * * * /home/rsteff/ShellScripts/x10-lights-off.sh

I edited (to make the just recommended change -- 1-59/5...) and saved
the old version of crontab.bak (the one just created) and restored it
with crontab crontab.bak. However, it still does not run the shell
scripts to turn the lights on and off.

I am getting mail from cron, though. The important part is:
-------------------------------------------------------------
/home/rsteff/ShellScripts/x10-lights-on.sh: line 6: x10: command not found
/home/rsteff/ShellScripts/x10-lights-on.sh: line 9: x10: command not found
-------------------------------------------------------------

That got me to wondering why I could, using a terminal window, run the
script from the /home/rsteff/ShellScripts directory and have it work,
but cron couldn't get it to work.

Then I remembered running make install x10 to fix something and seeing
it installed in /home/rsteff/bin. The shell scripts x10-lights-on.sh and
x10-lights-off.sh did not have full path names to the program x10. By
adding them, cron was able to find the program, and now it works as
expected.

Thanks for indirectly showing me what was wrong. I think I actually
learned something this way!

-- 
Regards,

Dick Steffens




More information about the PLUG mailing list