Cron on Ubuntu silently truncates commands to 999 characters
serverfault.com
serverfault.com
Running `grep -R 1000 .` on `apt-get-source cron` turns up:
./cron-3.0pl1/cron.h:#define MAX_COMMAND 1000 /* max length of internally generated cmd */
Further grepping for MAX_COMMAND gives you this gem: /* Everything up to the next \n or EOF is part of the command...
* too bad we don't know in advance how long it will be, since we
* need to malloc a string for it... so, we limit it to MAX_COMMAND.
* XXX - should use realloc().
*/
ch = get_string(cmd, MAX_COMMAND, file, "\n");
XXX - should use realloc().Really?
> Experientially, there is a 999 character truncation per line on all of my Ubuntu machines, although I have not yet found any related explanatory documentation.
> I've tested on Ubuntu 10.04, 12.04, and 14.04, and the 999 character count is started at the first non-whitespace character past the schedule.
This should be documented but I don't see the big deal.
cron
----
0 0 1 1 * script.sh
script.sh
---------
#!/bin/bash
very-long-command-to-stop-service
start-service