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

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?

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?