5

I'm planning to create scheduled tasks and I want linux to handle those tasks using crontab.

Note: some tasks have different schedules and some are the same

[crontab file (schedule.cron)]

* * * * * /application/monitor -source1
* * * * * /application/monitor -source2
* * * * * /application/monitor -source3
...
* * * * * /application/monitor -source500
* * * * * /application/monitor -source501
* * * * * /application/monitor -source502
...
* * * * * /application/monitor -source1000
* * * * * /application/monitor -source1001
* * * * * /application/monitor -source1002
  • Is your question if cron will work correctly with such a large file, or how to create the contents of the file automatically? – TheSchwa Aug 10 '14 at 8:08
  • @The I'm pretty sure it is if it will work... – Tim Aug 10 '14 at 8:10
2

I am pretty sure there is no limit to the length of a cron file (maybe 65536 chars/lines due to 32bit limits?).

Some people on Stack overflow and Server Fault thought there was a limit:

(2011) Ubuntu Debian is limited to 256 (and I just ran into that). FreeBSD will happily accept 600 entries. I haven't checked beyond that, but 600 crontab entries ought to be enough for anyone :)

But that wasn't the accepted answer, this was and it says there isn't one.

There doesn't appear to be a documented limit to the number of crontab entries allowed. So, short of checking the source code to the specific version you're using, perhaps the BUG entry in the crontab manpage could be helpful:

Although cron requires that each entry in a crontab end in a newline character, neither the crontab command nor the cron daemon will detect this error. Instead, the crontab will appear to load normally. However, the command will never run. The best choice is to ensure that your crontab has a blank line at the end.

And on Unix and Linux, this was the answer:

cronies limit seems to depend on the filesystem (maximum file size) as the cron daemon stores the crontab entries per user in a linked list - see user.c from cronie for details. This means the maximum number of job entries for crontab is basically unlimited.

So I'm pretty sure that it is unlimited, but you need to have that blank line at the end. :)

  • Thank you for your answer, I've tried it my self just a while ago in my Ubunt Virtual Machine while waiting for some answers, and 1500 lines in crontab works just fine. :) – prix Aug 10 '14 at 8:32
  • @prix good to know :) – Tim Aug 10 '14 at 8:50
1

This still comes up on top for those searching for crontab limits (myself included). So I'll post an update for anyone else interested:

As of 2019, Cron on Debian will enforce a maximum crontab line count to prevent a malicious user from creating an excessivly large crontab. According to the Debian change log.

  • Version 3.0pl1-133 introduced a limit of 1000 lines on March 10
  • Version 3.0pl1-134 relaxed this limit to 10000 lines on June 23

Debian-based distros such as Ubuntu and Mint will likely adopt these changes soon™

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.