6

I need a way to undeploy all my applications from Glassfish. Normally, I would use asadmin undeploy --target=[target] [appname]" for each application. My problem is that I don't know the name of all applications that are present on the server. Is there a command that would allow me to just undeploy everything? Thanks.

1
  • perhaps easier to delete the domain and then re-create..
    – Thufir
    Commented Nov 6, 2017 at 23:24

2 Answers 2

13

You can create a bash script like this one:

#!/bin/bash

ASADMIN=(path to Glassfish asadmin executable)

function undeploy_all {
    for p in $*; do
        echo "Undeploying $p..."
        $ASADMIN undeploy $p
    done;
}

apps=`$ASADMIN list-applications -t | awk '{print $1;}'`

undeploy_all $apps

When you run it, it will undeploy all deployed applications automatically. It needs awk. Make sure to configure the ASADMIN variable with the path to asadmin.

2
  • Hi Johny can you please tell me what is awk.
    – ziMtyth
    Commented May 20, 2018 at 11:06
  • 1
    @ziMtyth awk is an interpreter for the AWK Programming Language, which is used for manipulation of data files, text retrieval and processing. Is useful for processing the output of commands, like in the script. The book for gawk is a complete reference for learning it if you are interested.
    – Johny
    Commented Jun 21, 2018 at 15:06
5

While there isn't an 'undeploy everything' command, there is a list-applications command. This page describes list-applications and some other commands that will help you achieve your goal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.