ksh – Process

— Get process id of current process
$ echo $$
6113
— shows process id
$ ps
PID TTY TIME CMD
2050 pts/2 00:00:00 ps
6113 pts/2 00:00:00 ksh

Useful when creating a unique temp file example TEMPFILE=/tmp/tmpfile.$$

— Get process id of last background id
$ sleep 10 &
[1] 2078
$ echo $!
2078

— Print parent process id
$ print $PPID
6048

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s