Linux – Crontab maximum command length

cronlinux

Is there a limit of characters a command in a crontab could be ?

I have a crontab with a 178 characters command and it seems to be truncated at 164 when executed. I can tell this number from the e-mail I receive and from the vi colors changing from that point.

So, is it an "official" limitation ? I can't find any documentation about this.

Best Answer

Wow, I found what my problem is and it had nothing to do with line length.

It turns out that my command had a % (percent sign) in it, which has a special meaning in crontab. It is used to input text to STDIN (see Why is my crontab not working, and how can I troubleshoot it?).

So I had to escape it. My command which was:

gzip -c /path/to/a/file > /backup/dir/file-$(date +%F_%T).gz

becomes

gzip -c /path/to/a/file > /backup/dir/file-$(date +\%F_\%T).gz
Related Topic