<p>I need to get error pods above five days.
The below commands is working well for the pods which is below five days. Could anyone please let me know on how to get pods which is above 5 days only. It should not show the error pods which is below 5 days.</p>
<pre><code>kubectl get pods --all-namespaces --sort-by=.metadata.creationTimestamp | awk 'match($6,/^[1-4]d|^[1-900]+h|^[1-900]+m|^[1-900]+s/) {print $0}' | grep &quot;Error&quot; 
</code></pre>

<p>I got two options for you:</p>
<pre><code>kubectl get pods --sort-by=.metadata.creationTimestamp | awk 'match($5,/[6-9]d|[0-9][0-9]d|[0-9][0-9][0-9]d/) {print $0}' | grep -i error
</code></pre>
<p>or</p>
<pre><code>kubectl get pods --field-selector=status.phase=Pending --sort-by=.metadata.creationTimestamp | awk 'match($5,/[6-9]d|[0-9][0-9]d|[0-9][0-9][0-9]d/) {print $0}'
</code></pre>
<p>Both will only show pods that exists for 6 days or longer. First option will also look for those with errors and the second one will show only those with the <code>Status=Pending</code>.</p>
