1: #!/bin/bash
2: # Try this under bash, ksh and sh
3:
4: trap huphandler HUP
5: trap '' QUIT
6: trap exithandler TERM INT
7:
8: huphandler()
9: {
10: echo 'Received SIGHUP'
11: echo "continuing"
12: }
13:
14: exithandler()
15: {
16: echo 'Received SIGTERM or SIGINT'
17: exit 1
18: }
19: ## Execution starts here - infinite loop until interrupted
20: # Use ":" or "true" for infinite loop
21: # SECONDS is built-in to bash and ksh. It is number of seconds since script started
22: : is like a comment, but it is evaluated for side effects and evaluates to true
23: seconds=0
24: while : ; do
25: # while true; do
26: sleep 5
27: seconds=$((seconds + 5))
28: echo -n "$SECONDS $seconds - "
29: done
| last modified 22/03/2012 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |