Skip to content

Instantly share code, notes, and snippets.

@mutsune
Created October 17, 2018 07:40
Show Gist options
  • Save mutsune/6f5904f3bd9eab380deaf95f6f2f3689 to your computer and use it in GitHub Desktop.
Save mutsune/6f5904f3bd9eab380deaf95f6f2f3689 to your computer and use it in GitHub Desktop.
Convert `ps -o etime` format into seconds https://stackoverflow.com/a/14653443
#!/usr/bin/awk -f
BEGIN { FS = ":" }
{
if (NF == 2) {
print $1*60 + $2
} else if (NF == 3) {
split($1, a, "-");
if (a[2] != "" ) {
print ((a[1]*24+a[2])*60 + $2) * 60 + $3;
} else {
print ($1*60 + $2) * 60 + $3;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment