What command can I run to get the oldest pod name?


Jar 99

I want to get the name of the oldest pod in the script. It appears that I should be able to run kubectl get po --no-headers=trueAGE-sort, then sort by AGE, then pipe to head -n1|awk '{print $1}', but can't seem to sort by job. I am running kubectl 1.7.9.

David Miz

AGE times are in an irregular format ( 23m, 2d) and are difficult to sort, but you can ask to kubectlwrite out the time when the pod started. The time will be displayed in ISO 8601 format which is very easy to classify. You can use this recipe to get the oldest pods that may work for you:

kubectl get pods \
    --no-headers \
    --output=custom-columns=START:.status.startTime,NAME:.metadata.name \
| sort \
| head -1 \
| awk '{print $2}'

The kubectlcommand asks to print only the start time and name of each pane in order.

Also consider kubectl get pods -o jsonthat this will give you very large very detailed JSON records. If you have a preferred full-featured scripting language, you can use it separately here, or use a command-line tool jqto try and digest it further. Any field path can also be inserted into the custom-columnsoutput specification.

Related


What command can I run to get the oldest pod name?

Jar 99 I want to get the name of the oldest pod in the script. It appears that I should be able to run kubectl get po --no-headers=trueAGE-sort, then sort by AGE, then pipe to head -n1|awk '{print $1}', but can't seem to sort by job. I am running kubectl 1.7.9

How can I get the directory name where I run the command

Travis Heeter I have a folder like this C:\repos\3333-new-feature. Then from that location, in a git bash terminal, run a bat file: /c/repo/3333-new-feature $ myBat.bat One of the directives in bat should use the directory name like this: git flow feature sta

How to get the oldest person's name using UNIX command

roof tiles I want to get the name of the oldest person in a Unix data file. How can I do this? Rob,20 Tom,30 I tried the following but it only gives me the max age. awk -F"," '{print $2}' age.txt | sort -r | head -1 robert $ cat file | awk -F, '{print $2,$1;

Can I get the classic "Run Command" window

Ranjith Ramachandra I love unity, but I hate Alt+ F2dashes. Is it possible to remap Alt+ F2so that things look exactly like the old Alt+F2 I know what I want is going back in time, but I really like that quick command executor from the old gnomes. I can use Ct

What version of Ubuntu snapcraft can run on the oldest version?

Andrea Lazzarotto One of the advantages of Snap packages over DEB packages is that dependencies are included in the package, so even if the system is updated, Snaps should not break. Some legacy programs that were supposed to run on top of Qt3 have been remove

What version of Ubuntu snapcraft can run on the oldest version?

Andrea Lazzarotto One of the advantages of Snap packages over DEB packages is that dependencies are included in the package, so even if the system is updated, Snaps should not break. Some legacy programs that were supposed to run on top of Qt3 have been remove

How can I run a command with the same name as a PowerShell alias?

Saravana I have some command line utilities with the same name as PowerShell aliases. For example where(alias Where-Object) obscures the tools that come with whereWindows . In bash, I can use \or commandlike \whereor skip aliases command where. Is there someth

How can I run a command with the same name as a PowerShell alias?

Saravana I have some command line utilities with the same name as PowerShell aliases. For example where(alias Where-Object) obscures the tools that come with whereWindows . In bash, I can use \or commandlike \whereor skip aliases command where. Is there someth

How can I run a command with the same name as a PowerShell alias?

Saravana I have some command line utilities with the same name as PowerShell aliases. For example where(alias Where-Object) obscures the tools that come with whereWindows . In bash, I can use \or commandlike \whereor skip aliases command where. Is there someth

How can I run a command with the same name as a PowerShell alias?

Saravana I have some command line utilities with the same name as PowerShell aliases. For example where(alias Where-Object) obscures the tools that come with whereWindows . In bash, I can use \or commandlike \whereor skip aliases command where. Is there someth

How can I get the applicationId when I run the command with yarn?

vy32 I am using yarn jarcommand to submit a job to run a distributed shell. How to get applicationId programmatically? Abhinav To get the application ID, you need to go to the ResourceManager web UI , which is accessible via your node's IP address (resource ma

How can I get the applicationId when I run the command with yarn?

vy32 I am using yarn jarcommand to submit a job to run a distributed shell. How to get applicationId programmatically? Abhinav To get the application ID, you need to go to the ResourceManager web UI , which is accessible via your node's IP address (resource ma

How can I get the total time a command has run?

username I know you can get the compile time of each function using: xcodebuild -workspace App.xcworkspace -scheme App clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt or thi

How can I get the total time a command has run?

username I know you can get the compile time of each function using: xcodebuild -workspace App.xcworkspace -scheme App clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt or thi

How can I get the total time a command has run?

username I know you can get the compile time of each function using: xcodebuild -workspace App.xcworkspace -scheme App clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt or thi

How can I get the total time a command has run?

username I know you can get the compile time of each function using: xcodebuild -workspace App.xcworkspace -scheme App clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt or thi

How can I get the total time a command has run?

username I know you can get the compile time of each function using: xcodebuild -workspace App.xcworkspace -scheme App clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt or thi

How can I get the name of the last executed command?

constitution Example: I type man ls, not I just want to get man. I can get it by using !!, man lsbut how do I get it man? Jimmy Ji You can use !!:and a word indicator to select specific words from the last command typed . As a word indicator, you need 0. You m

How can I get the name of the last executed command?

constitution Example: I type man ls, not I just want to get man. I can get it by using !!, man lsbut how do I get it man? Jimmy Ji You can use !!:and a word indicator to select specific words from the last command typed . As a word indicator, you need 0. You m