OpenWrt Forum Archive

Topic: cron broken in BB? cron.err user root: parse error at 30 [solved]

The content of this topic has been archived on 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi, this is what I'm getting:

root@wr741nd:~# /etc/init.d/cron start
root@wr741nd:~# logread
.
.
Tue Mar 25 13:13:56 2014 cron.info crond[1150]: crond: crond (busybox 1.19.4) started, log level 5
Tue Mar 25 13:13:56 2014 cron.err crond[1150]: user root: parse error at 30
.
.

My /etc/contabls/root

root@wr741nd:~# cat /etc/crontabs/root
# crontab
05 30 * * * reboot

That crontab worked in AA, but now in in BB  r40010 does not. What could be possibly wrong?

edit: with empty /etc/contabls/root (only the first # crontab line) it does not report that error, but syntax is ok even if I put the line with reboot, "at 30" is meant where?

(Last edited by nozombian on 28 Mar 2014, 09:11)

cron seems to work for me in last weeks Barrier Breaker

/etc/init.d/cron enable
/etc/init.d/cron start
echo "54 14 * * * reboot" | crontab -

does a reboot at 14:54

Well, it works on my wr1043nd too, but why not on wr741n? What does that parse error actually mean? Parse of what?

(Last edited by nozombian on 26 Mar 2014, 13:39)

crontab -l wrote:

# minuto(0-59) hora(0-23) mesdia(1-31) mes(1-12) diasemana(0-6) comando >/dev/null 2>&1
# 25 6 * * 1 /usr/bin/logger -p cron.info -t network "Scheduled restart" && reboot >/dev/null 2>&1

I always put a reminder in the first line.

nozombian wrote:

What does that parse error actually mean? Parse of what?

Usually it means, that you have an error in your crontab.

Follow nilfreds suggestion to put the reminder into the crontab, and your problems will be solved (sooner or later, hopefully ;-)

When copying your cat output into a text editor, it is exactly 28 byte long. Since crond is complaining about a parse error at byte 30 I suppose its complaining about windows new lines (one byte more per line break). It likely chokes on the "\r" in "reboot\r\n".

Funny: I tried myself on BB r40004, entered "05 30 * * * reboot" *manually*, no new lines.
The previously working crontab now results in

Wed Mar 26 19:27:30 2014 cron.info crond[969]: crond: crond (busybox 1.19.4) started, log level 5
Wed Mar 26 19:27:30 2014 cron.err crond[969]: user root: parse error at 30

I don't get this error when I enter  "05 23 * * * reboot"

Edit: When I change it to "05 32 * * * reboot", I get

Wed Mar 26 19:45:06 2014 cron.info crond[967]: crond: crond (busybox 1.19.4) started, log level 5
Wed Mar 26 19:45:06 2014 cron.err crond[967]: user root: parse error at 32

So Nilfred was right smile

(Last edited by tmo26 on 26 Mar 2014, 19:47)

Nilfreds suggestion is implemented in freetz since long time:
http://abload.de/img/freetz_crontab_with_s2mu4x.jpg



I LOLed when I remembered, that (coming from freetz) I implemented this on my MR3020 with AA12.09 about 10 months ago smile

http://abload.de/img/openwrtaa1209_crontabsxu9a.jpg



How to add a little help to LuCi crontab page:

edit /usr/lib/lua/luci/model/cbi/admin_system/crontab.lua

add this:  Help: mins - hours - day of month - month - day of week (0=Sun)

In case those changes don't show up in Luci → delete the luci cache files in /tmp

(Last edited by tmo26 on 26 Mar 2014, 20:22)

Thanks for the tip, but how could possibly CRLF get to openwrt when i'm doing everything from inside vi via putty? So the solution is to put a longer dummy "reminder" line? You are you kidding me, right? big_smile

edit: I desperately pasted nilfred's reminder, but still getting parse error at 30 roll Tmo26 is right, when I modify to 05 32 * * * reboot, i get parse error at 32. Please kick me into the head, I don't understand what should I do to correct that wink Btw. no CRLFs there:

root@wr741nd:/etc/crontabs# hexdump -C root
00000000  23 20 6d 69 6e 75 74 6f  28 30 2d 35 39 29 20 68  |# minuto(0-59) h|
00000010  6f 72 61 28 30 2d 32 33  29 20 6d 65 73 64 69 61  |ora(0-23) mesdia|
00000020  28 31 2d 33 31 29 20 6d  65 73 28 31 2d 31 32 29  |(1-31) mes(1-12)|
00000030  20 64 69 61 73 65 6d 61  6e 61 28 30 2d 36 29 20  | diasemana(0-6) |
00000040  63 6f 6d 61 6e 64 6f 0a  30 35 20 33 32 20 2a 20  |comando.05 32 * |
00000050  2a 20 2a 20 65 63 68 6f  20 22 72 65 62 6f 6f 74  |* * echo "reboot|
00000060  22 0a                                             |".|
00000062

(Last edited by nozombian on 28 Mar 2014, 08:29)

The reminder says: mins - hours - .....

Your crontab reads 05 30 .... -> crontab doesn't know what 05 minutes after the 30th hour means, because the allowed range for hours is only 0-23

You simply put hours and mins the wrong way in your crontab.
That's why you get an error at "30" or "32" but you will not get an error if you change 30 to e.g. 23.

And you will not get an error when you put it the other way round: 30 05 (right) instead of 05 30 (wrong).

smile

Thanks for the kick, stupid me smile I must have had that error in there at least for a year, so I did not think for a moment it could be wrong. On wr1043nd I tested with another time, that's why it worked. Shame on me.

The discussion might have continued from here.