nithir revised this gist . Go to revision
No changes
nithir revised this gist . Go to revision
No changes
nithir revised this gist . Go to revision
1 file changed, 19 insertions
trap.sh(file created)
| @@ -0,0 +1,19 @@ | |||
| 1 | + | # trap "systemctl restart $SERVICES" INT QUIT TERM KILL EXIT | |
| 2 | + | ||
| 3 | + | # la commande trap va capturer: | |
| 4 | + | ||
| 5 | + | # INT, les interruptions volontaire | |
| 6 | + | # QUIT, ne semble pas faire son boulot | |
| 7 | + | # TERM, je ne sais plus | |
| 8 | + | # KILL, capture les signal d'interruption | |
| 9 | + | # EXIT, semble faire le boulot de QUIT | |
| 10 | + | ||
| 11 | + | # On peut aussi utiliser une fonction | |
| 12 | + | ||
| 13 | + | function cleanup() | |
| 14 | + | { | |
| 15 | + | # ... | |
| 16 | + | } | |
| 17 | + | ||
| 18 | + | trap cleanup EXIT | |
| 19 | + | ||
Newer
Older