Skip to content

Instantly share code, notes, and snippets.

@tripleee
Created August 17, 2016 06:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripleee/2a1622fdf8ab080ce3b36d95af60010a to your computer and use it in GitHub Desktop.
Save tripleee/2a1622fdf8ab080ce3b36d95af60010a to your computer and use it in GitHub Desktop.
starttime - print start time of a process on Linux
#!/bin/sh
# http://stackoverflow.com/a/38740102/874188
for p; do
printf "/proc/%i/stat\0" "$p"
done |
xargs -r0 awk -v ticks="$(getconf CLK_TCK)" 'NR==1 { now=$1; next }
{ print strftime("%c " $1 " " $2, systime() - (now-($22/ticks))) }
' /proc/uptime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment