in my bash script I want to add timeout for the lvresize command so if the command is waiting ,
I will exit after 5 second , as the follwing:
timeout 5 lvresize -L 1M /dev/mapper/rootvg-home
Rounding size to boundary between physical extents: 32.00 MiB
WARNING: Reducing active and open logical volume to 32.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce home? [y/n]:
but from some unclear reason timeout not works on lvresize?
why? timeout not exit the command after 5 sec?
Whyever this fails (my assumption would be lvresize ignoring the TERM signal), this a terrible approach, as lvresize's real task might take that long and you really don't want to kill it while it works.
Instead, ask for confirmation separately (with timeout if need be) and then run lvresize uninterrupted.