[prev in list] [next in list] [prev in thread] [next in thread]
List: freebsd-hackers
Subject: Re: verifying a given jail is running
From: Miroslav Lachman <000.fbsd () quip ! cz>
Date: 2021-08-18 17:19:22
Message-ID: 71fb0edd-2b8a-e9ec-ed7e-ca8d6cdfff17 () quip ! cz
[Download RAW message or body]
On 18/08/2021 18:21, Dan Langille wrote:
> I could use it like this in a shell script.
>
> jls -j freshports > /dev/null 2>&1
> if [ $? = 0 ] ; then
> echo jail is running
> else
> echo jail is not running
> fi
>
> The main reason I need this: Verifying the jail is running before
> continuing with a script.
You can save one line with this:
if jls -j freshports > /dev/null 2>&1 ; then
echo "jail is running"
else
echo "jail is not running"
fi
Or if you don't need the echoed output and just need to stop script
execution:
jls -j freshports > /dev/null 2>&1 || exit 5
Miroslav Lachman
PS: Use jls -d if dying jail is also accepted as running jail (see man jls)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic