Lines that were printed and never written#
Each program printed at once, waited, and was killed after one or two seconds with output redirected to a file:
| Program | Signal | Printed | In the file |
|---|---|---|---|
| Python, two lines | KILL | 2 lines | 0 bytes |
Python with -u, two lines | KILL | 2 lines | 2 lines |
| Python, 2,000 lines | KILL | 2,000 lines | 41,014 bytes, ending mid-line in processing order |
| Python, 2,000 lines | TERM | 2,000 lines | 41,014 bytes, the same cut |
| Node 24, two lines | KILL | 2 lines | 2 lines |
grep in a pipeline, three matches | KILL | 3 lines | 0 bytes |
The last complete line in the third file was processing order 1913. The program had printed up to 1999. Taking the last line as the place where the job stopped would be wrong by 86 orders. Run with Python 3.12.
TERM behaved like KILL here, because Python's default response to it ends the process without flushing. A program that handles the signal and exits normally flushes. Node's lines survived in this fixture, which wrote to a file; do not extend that to pipes without testing.
The grep row is a reminder that a filter in front of the file buffers too. grep --line-buffered writes each match.
Separate "never ran" from "lost"#
| Evidence | Never started | Ran and lost output |
|---|---|---|
| Exit status | 126, 127, or a scheduler error | 137 or 143 |
| File the job creates first | Absent | Present |
| Database rows or requests it makes | None in the window | Some |
| Start recorded by the scheduler | No | Yes |
| Log ends in the middle of a line | No log | A strong sign of a cut buffer |
137 is 128 plus signal 9, so the process received KILL. It does not say who sent it: the kernel's memory killer, a container runtime and a person all produce it. Read the memory events or the runtime's record before you write "out of memory".
Change the capture before the next run#
- Python:
PYTHONUNBUFFERED=1, orprint(..., flush=True)at the lines that mark progress. - C programs that use stdio:
stdbuf -oL command, when the program does not set its own buffering. - Progress that matters: write it to the database in the same transaction as the work. A log line says the program passed a point, and a committed row says the work is done.
What to hand over#
- The exit status and who recorded it.
- The file's size and whether the last line is complete.
- How output was captured, with every process in the pipeline.
- An independent trace of progress, or the sentence "progress unknown after order 1913".
The word "after" in item 4 matters. The log gives a lower bound on progress.
Worked example#
This example is fictional. A nightly job's log is empty, and Ana hands it over as "did not run, rerun it". Ben sees status 137 and 1,950 charges created in the job's window. The job had run and lost its output. A rerun without a check would have charged those accounts again. He finds the first uncharged account from the table and resumes there.
Resuming safely is the topic of a backfill in progress. Return to handing over evidence.