NeilM
Posts: 8
Joined: Sat Jul 07, 2012 11:25 pm

Crontab Length Limit?

Sun Aug 30, 2015 3:10 pm

Is there a limit to the size (no. of lines?) of a crontab file? I am up to 731 lines, and nothing beyond line 590-ish is running. I am on Debian Wheezy (3.18.11+ #781 PREEMPT Tue Apr 21 18:02:18 BST 2015 armv6l).

What I am doing is running something hourly (one line), then running something at dawn and dusk every day of the year. This time is different every day, so the only way my poor brain could think of to cope with that is to use a separate line for each event (365 x 2 = 730 lines). I did a bit of intergooglewebbing, but not much is out there on this issue...

Any thoughts, either on the limit question, or on making the implementation of my requirements a little more elegant?

Thanks, Neil.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Crontab Length Limit?

Sun Aug 30, 2015 3:27 pm

I've never heard of a limit and I can think of no rational reason why there should be a limit. If I had the inclination to really test it, I'm pretty sure I'd find that there was no such limit.

That said, there are certainly better ways to do what you are trying to do. In general, I think people way mis-use/abuse and over-use cron (specifically so on the RPi). I put this down to the fact that the RPi is the first really affordable Linux box ever and people who never would have used Unix or Linux now find themselves able to do so.

Anyway, what I would do is write a shell script that waits for the appropriate time (based on its internal logic). Then schedule that script to run at midnight every day.

Actually, what *I* would do is not use cron at all - and just have the script be always running (on an otherwise unused virtual console) - dispatching the sub-process each day at the anointed hour.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
rpdom
Posts: 14416
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Crontab Length Limit?

Sun Aug 30, 2015 4:12 pm

Joe Schmoe wrote:Actually, what *I* would do is not use cron at all - and just have the script be always running (on an otherwise unused virtual console) - dispatching the sub-process each day at the anointed hour.
So, what you really mean is that you'd write your own version of cron?

I admit I have done something like that when I couldn't get cron to do what I wanted, but it has improved over the last 30 years or so ;)

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Crontab Length Limit?

Sun Aug 30, 2015 4:47 pm

So, what you really mean is that you'd write your own version of cron?
No, you need to read more carefully.

I'm not talking about re-inventing cron at all.

I'm talking about a specific solution to OP's problem.

See, he has a database of dusk/dawn times for each day of the year (presumably, in his location). He wants to launch a program at dawn and dusk of each day.

So, the logic is:

:loop
Wait until midnight
Lookup today's date
Do a database lookup of dawn and dusk based on that date
Wait until "dawn"
Launch program
Wait until "dusk"
Launch program
goto loop

Hardly re-inventing cron.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
DougieLawson
Posts: 35340
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Crontab Length Limit?

Sun Aug 30, 2015 7:59 pm

NeilM wrote:
Any thoughts, either on the limit question, or on making the implementation of my requirements a little more elegant?
The sunwait program is a lot more elegant and only needs two lines in crontab to work for the whole year.

http://www.raspberrypi.org/forums/viewt ... 91&t=71010
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Troubleshooting”