cron logging level 4 not clear for understanding
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cron (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
I turned on logging level 4 for cron(logging failed jobs). I think it's not clear for understanding which job has been failed:
Aug 28 21:58:22 x05 CRON[14697]: (CRON) error (grandchild #14709 failed with exit status 1)
Aug 28 22:03:30 x05 CRON[17572]: (CRON) error (grandchild #17599 failed with exit status 255)
Aug 28 22:06:52 x05 CRON[17560]: (CRON) error (grandchild #17579 failed with exit status 1)
Aug 28 22:09:33 x05 CRON[17575]: (CRON) error (grandchild #17595 failed with exit status 1)
This format will be much better:
Aug 28 22:16:01 x05 CRON[22722]: (root) ERR ([22726] ls /nowhere is failed withstatus 2)
Aug 28 22:17:01 x05 CRON[23005]: (root) ERR ([23009] ls /nowhere is failed withstatus 2)
Aug 28 22:18:01 x05 CRON[23165]: (root) ERR ([23169] ls /nowhere is failed withstatus 2)
Aug 28 22:19:01 x05 CRON[23313]: (root) ERR ([23317] ls /nowhere is failed withstatus 2)
My small patch to fix this:
--- cron-3.
+++ cron-3.
@@ -491,18 +491,24 @@ child_process(e, u)
getpid(), pid, WEXITSTATUS(
if (log_level & CRON_LOG_JOBFAILED) {
+ char *x;
+ char logcmd[MAX_COMMAND + 8];
+ snprintf(logcmd, sizeof(logcmd), "[%d] %s", (int) job_pid, e->cmd);
+ x = mkprints((u_char *)logcmd, strlen(logcmd));
+
if (WIFEXITED(waiter) && WEXITSTATUS(
status = waiter;
- snprintf(msg, 256, "grandchild #%d failed with exit "
- "status %d", pid, WEXITSTATUS(
- log_it("CRON", getpid(), "error", msg);
+ snprintf(msg, 256, "%s is failed with"
+ "status %d", x, WEXITSTATUS(
+ log_it(usernm, getpid(), "ERR", msg);
} else if (WIFSIGNALED(
status = waiter;
- snprintf(msg, 256, "grandchild #%d terminated by signal"
- " %d%s", pid, WTERMSIG(waiter),
+ snprintf(msg, 256, "%s terminated by signal"
+ " %d%s", x, WTERMSIG(waiter),
WCOREDUMP
- log_it("CRON", getpid(), "error", msg);
+ log_it(usernm, getpid(), "ERR", msg);
}
+ free(x);
}
}