Read logs from the previous Pod container instance
Build a paste-ready command, then review its compatibility and effects before running it.
kubectl -n <namespace> logs <pod> --previous --tail=100Complete required fields to copy the generated command.
read-onlyno known side effects Compatibility
Linux + macOS + WindowsVerified for Linux, macOS, Windows using bash, zsh, powershell syntax.
Operational knowledgereview due 2027-01-20
Requirementskubectlkubectl must be installed and available on PATH.
Version supportkubectl Current supported releasesVerified for linux, macos, windows using bash, zsh, powershell syntax; consult compatibility notes for platform-specific differences.
Expected signals2026-07-24T10:11:02Z starting apiRepresentative successful output; values vary with the selected target and system state.
Known errorskubectl: command not foundkubectl is missing or is not available on PATH.
Verifykubectl -n {{namespace}} logs {{pod}} --previous --tail=100The output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01kubectlCommandRuns the kubectl stage of this one-liner.
02-nOptionApplies the command-specific numeric, dry-run, or non-resolving mode.
03<namespace>ParameterA value supplied in the Fill parameters section.
04logsArgumentPasses logs to kubectl.
05<pod>ParameterA value supplied in the Fill parameters section.
06--previousOptionConfigures kubectl with the --previous option.
07--tail=100OptionStarts with only the requested number of recent lines.
Example input
kubectl -n default logs api-7d9f8c6b5-x2k4m --previous --tail=100
Example output
2026-07-24T10:11:02Z starting api
2026-07-24T10:11:04Z fatal: database connection timeout
Illustrative output — exact values vary by system and data.
Official sources