2009-04-05 21:15:10     IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

Document created by Aaronwu Employee on Aug 15, 2013
Version 1Show Document
  • View in full screen mode

2009-04-05 21:15:10     IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72181  

 

Hi

 

i am try using Cron running a script to do something, but i found some strange things, i made a testing...

 

1. a testing script, same following

 

------------------

 

#!/bin/sh

 

A=30

 

B=29

 

if [ $B -gt $A ]

 

then

 

    echo "B > A" > /tmp/test.out

 

else

 

    echo "B < A" >>  /tmp/test.out

 

fi

 

-------------------

 

2. directly running this script using " root:~>/bin/sh test.sh ", working good, show B < A

 

3. put this script to /etc, and edit /etc/config/crontab, then start cron

 

--------------

 

0 * * * * root /bin/sh /etc/test.sh

 

--------------

 

4. when cron runing this script, always show B > A ???

 

i used 2008R1.5-RC3 and running testing script on bf537 stamp board. and used " Core Applications -> Cron "

 

Thanks

 

QuoteReplyEditDelete

 

2009-04-05 21:24:48     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 72182  

 

are you sure your script is running at all ?  your syntax looks wrong.  there is no "user" argument in the crontab format.

 

QuoteReplyEditDelete

 

2009-04-05 21:32:15     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72183  

 

i tested more than 20 times, the result same, and i using root for this script within crontab, it is

 

0 * * * * root /bin/sh /etc/test.sh

 

QuoteReplyEditDelete

 

2009-04-05 21:38:26     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 72184  

 

like i said, your crontab line is wrong.  there is no user argument.  that is specific to vixie-cron (and similar), and i doubt you're using that implementation on the board.

 

QuoteReplyEditDelete

 

2009-04-05 21:50:25     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72185  

 

thanks Mike,

 

please take a view uClinux-dist-2008R1.5-RC3/user/cron/README, we must need a user to running crontab, if no, will show a error

 

-----------

 

crontab has malformed input line 1

 

--------------

 

BTW, i used msh

 

QuoteReplyEditDelete

 

2009-04-05 21:55:17     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72187  

 

and i am sure i used cron, not vixie-cron.

 

QuoteReplyEditDelete

 

2009-04-05 22:01:26     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 72189  

 

use the cron that's part of busybox.  that's been tested and it's known to work fine.

 

you did run crond right ?

 

QuoteReplyEditDelete

 

2009-04-05 22:07:04     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72190  

 

i am not running crond, do you mean let me using crond of busybox, not cron?

 

QuoteReplyEditDelete

 

2009-04-05 22:18:44     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 72191  

 

it doesnt matter which iimplementation is used wrt crond.  if you dont run the cron binary, then there is nothing to run the jobs.  if you use the user/cron/ version, you still need to start the cron daemon yourself.

 

QuoteReplyEditDelete

 

2009-04-05 22:35:19     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72192  

 

oh, i see, i did, i start cron with " cron &", and i tested just echo something to a file, the cron and script working good, just using IF condition can't working, strange :-(

 

QuoteReplyEditDelete

 

2009-04-06 05:26:56     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72205  

 

as i make more testing, i found the WHILE till not working properly. does anybody who can make some testing on your board? and give me some suggestion? thanks

 

QuoteReplyEditDelete

 

2009-04-06 05:46:05     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 72207  

 

works fine for me with busybox crond

 

root:/> cat /etc/test.sh

 

#!/bin/sh

 

A=30

 

B=29

 

if [ $B -gt $A ]

 

then

 

    echo "B > A" > /dev/console

 

else

 

    echo "B < A" > /dev/console

 

fi

 

root:/> crontab -l

 

*/1 * * * * /bin/sh /etc/test.sh

 

root:/> B < A

 

root:/> tail -n1 /var/log/messages

 

Jan  1 00:08:01 blackfin cron.err crond[116]: USER root pid 143 cmd /bin/sh /etc/test.sh

 

QuoteReplyEditDelete

 

2009-04-06 06:25:08     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72209  

 

Thanks Mike,

 

i have tested with cornd of busybox, but that not working for me :(,  syslogd show correct, but actually script not running.

 

-------------

 

Mar  7 14:36:01 blackfin cron.notice crond[109]: USER root pid   0 cmd /bin/sh /etc/test.sh

 

------------

 

seems my busybox config setting missed something, Mike, can you please put your config file for me, :-)

 

QuoteReplyEditDelete

 

2009-04-06 09:06:52     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 72216  

 

hmm, you're using 2008R1.5 ... perhaps i was a bit hasty in suggesting busybox's crond here as it did not support no-mmu in the 2008R1.5 release.  it works fine in svn trunk though.

 

looks like msh, when run from crond, does not handle exit statuses properly.  it always sets it to 0 ... running a specific binary through strace shows that the child did exit non-zero, but msh doesnt care.

 

QuoteReplyEditDelete

 

2009-04-06 20:50:52     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72283  

 

i am tried use a small C program system function to call the test.sh script, and using cron to call this program, now my testing working :-),    www.edgepbx.cn/svn/nanoast/trunk/package/sources/run-script.c?root=edgepbx&view=markup

 

and i will try the svn for crond and cron...

 

QuoteReplyEditDelete

 

2009-04-06 21:05:31     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 72284  

 

i tested hush under both crons and it seemed to work properly.  but that still wouldnt help as the hush in the 2008R1.5 release probably wont work under no-mmu either.

 

we'll be switching to hush though after our next release at it is much better than msh ...

 

QuoteReplyEditDelete

 

2009-04-06 21:55:02     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Li Yuqian (CHINA)

 

Message: 72287  

 

Thanks Mike.

 

and i found 2008R1-RC8 still not wroking, and 2007R1.1-RC3 should be working properly.

 

FYI

 

QuoteReplyEditDelete

 

2009-04-27 02:56:33     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Tihomir Culjaga (CROATIA)

 

Message: 73259  

 

hello,

 

I have the same issue with cron.

 

when can we expect this to be fixed ?

 

Here is a script:

 

root:~> cat /etc/lighttpd-mem-leak-cleanup

 

#!/bin/sh

 

MAX_MEM=7000

 

A=`ps| grep lighttpd|grep -v bin|grep -v cron|grep -v grep`

 

echo `date` >> /var/log/cron_.log

 

echo "A=$A" >> /var/log/cron_.log

 

LIG_MEM=`echo $A | awk '{print $3}'`

 

LIG_PID=`echo $A | awk '{print $1}'`

 

echo "LIG_MEM=$LIG_MEM" >> /var/log/cron_.log

 

echo "LIG_PID=$LIG_PID" >> /var/log/cron_.log

 

echo "MAX_MEM=$MAX_MEM" >> /var/log/cron_.log

 

if [ 2 == 1  ]; then

 

        echo "test 2 == 1  NOT OK!" >> /var/log/cron_.log

 

else

 

        echo "test 2 == 1  OK!" >> /var/log/cron_.log

 

fi

 

if [ $LIG_MEM -gt $MAX_MEM ]; then

 

         echo "if LIG_MEM=$LIG_MEM -gt MAX_MEM=$MAX_MEM" >> /var/log/cron_.log

 

         echo "lighttpd memory too high... restarting!" >> /var/log/cron_.log

 

         /etc/init.d/lighttpd stop && sleep 2 && /etc/init.d/lighttpd start

 

else

 

         echo "memory is not too high... checking if lighttpd process is alive" >> /var/log/cron_.log

 

         if [ $LIG_PID = "" ]; then

 

            echo "LIG_PID=$LIG_PID" >> /var/log/cron_.log

 

            echo 'not alive... starting lighttpd!!!' >> /var/log/cron_.log

 

            /etc/init.d/lighttpd start

 

         else

 

            echo 'lighttp is alive! no action taken' >> /var/log/cron_.log

 

         fi

 

fi

 

exit 0;

 

root:~>

 

cat /var/log/cron_.log

 

Mon Jan 1 00:36:00 UTC 2007

 

A= 2023 root        868 S   lighttpd -f /etc/lighttpd.conf -D

 

LIG_MEM=868

 

LIG_PID=2023

 

MAX_MEM=7000

 

test 2 == 1  NOT OK!

 

if LIG_MEM=868 -gt MAX_MEM=7000

 

lighttpd memory too high... restarting!

 

root:~>

 

root:~>

 

Tihomir.

 

QuoteReplyEditDelete

 

2009-04-27 03:47:24     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 73261  

 

workarounds were already presented.  you can pick one.

 

QuoteReplyEditDelete

 

2009-04-27 13:06:33     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Tihomir Culjaga (CROATIA)

 

Message: 73300  

 

hi Mike,

 

can you suggest the best one ?

 

T.

 

QuoteReplyEditDelete

 

2009-04-27 13:26:31     Re: IF condition can't working with Cron/2008R1.5-RC3 on a stamp BF537?

 

Mike Frysinger (UNITED STATES)

 

Message: 73305  

 

"best" is a matter of opinion.  pick whatever one is easier for you to integrate into your setup.

 

QuoteReplyEditDelete

Attachments

    Outcomes