annotate bin/example/pid.sh @ 902:06d2cc0fe045

add signing key
author Jeff Hammel <k0scist@gmail.com>
date Thu, 16 Nov 2023 05:57:09 -0800
parents f8813ed3d015
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
674
df9d5093573e PID example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/bin/bash
df9d5093573e PID example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
df9d5093573e PID example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 PID=$$
df9d5093573e PID example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4
df9d5093573e PID example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 echo "The PID of this shell script is ${PID}"
df9d5093573e PID example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 ps auxwww | grep ${PID}
675
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
7
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
8 if which tempfile
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
9 then
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
10 PIDFILE=$(tempfile)
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
11 echo "PID file: ${PIDFILE}"
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
12 echo ${PID} > ${PIDFILE}
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
13 kill $(cat ${PIDFILE})
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
14 fi
f8813ed3d015 STUB: bin/example/pid.sh
Jeff Hammel <k0scist@gmail.com>
parents: 674
diff changeset
15
674
df9d5093573e PID example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 kill ${PID}