7 Replies Latest reply on Sep 11, 2013 3:36 AM by Mike Jones

    Server Cleanup Script and the cleanupAgent BLCLI

    Tal Abramson

      Hi

      I am trying to set up the Database and File Server Cleanup Script to clean my agents (using the CLEAN_AGENT option)

      So i followed the instruction from here:

      https://docs.bmc.com/docs/display/public/bsa82/Changing+Database+Cleanup+script+options+and+commands

       

      and i have set up the job options :

      ExecutionMode = CLEAN_AGENT

      ContinueOnError = true

      RetentionTime = 60


      But when i execute it i am getting this log output:

       

      InfoAug 19, 2013 2:05:06 PMAction launched: BladeLogic RSCD Agent temporary files older than 14 days cleanup (transactions, staging, ...)


      So its ignoring my RetentionTime settings

      Anyone know what i can be doing wrongly ?


      Also , how can i tell the full list of files ad folders been cleaned?

      I wish to know if the Trace file is also cleaned

        • 2. Re: Server Cleanup Script and the cleanupAgent BLCLI
          Michael Jantz

          @Siddu: as the mode CLEAN_AGENT actually is said to use the retention time I don't think the defaults Bill mentioned in the other thread are causing this problem.

           

          Excerpt from the script:

          # Script arguments
          
          MODE=$1
          CONTINUE_ON_ERR=$2
          DURATION=$3
          DURATION_DIST=$4
          RETENTION_DAYS=$5
          OBJECT_TYPE=$6
          ROLE=$7
          TARGET_LIST=$8
          MAX_MEGS=$9
          

           

          Parameters in this script are not given with flags, but are identified by their position. Parameters you leave blank will be disregarded, so if the parameters you stated are the only ones you set the job will use the value 60 for duration and not the retention_days as you intended.

           

          I'd think that all you need to do is set the parameters duration and duration_distribution to some value other than an empty string and everything should be fine.

          • 3. Re: Server Cleanup Script and the cleanupAgent BLCLI
            Tal Abramson

            I thought that might be the issue

            But i thought setting the "Flag runtime usage" and "Value runtime usage" to Ignore is enough

             

            And because DurationDistribution is a complex setting i was hoping to avoid setting it

            So i tried it using the default settings for all and its working as you said

             

            Thank you

            • 4. Re: Server Cleanup Script and the cleanupAgent BLCLI
              Mike Jones

              You could use the script that we updated and I have posted here - it uses getops for the parameters which you can set to ignore use as you wish in NSH script job https://communities.bmc.com/docs/DOC-26176

              • 5. Re: Server Cleanup Script and the cleanupAgent BLCLI
                Mike Jones

                Actually I should have read this more closely before jumping in and posting

                 

                For all other DB clean-up I would recommend using the script above, for Agent clean-up I would recommend writing your own NSH wrapper script because the agent clean command reads the staging directory from the server property and runs the clean up on that. If it was accidentally changed to /windows or /opt off it goes and deletes all files (that it can delete) older than the retention period.

                 

                The wrapper script that I wrote only executes the clean up if the property ends in /stage posted below FYI - I can email a copy if you want

                 

                 

                #!/bin/nsh

                #################################################################################################################################################

                #  Agent cleanup script

                #  Checks the server staging area property to ensure it ends with /stage

                #  then runs the Delete cleanup agent blcli command to remove older files

                #  Staging directory property check is required to enusre the the server property does not point to a location with other files e.g. /windows

                #

                #  Version 1.0 - Mike Jones

                #

                ##################################################################################################################################################

                 

                 

                #set -x

                 

                 

                while getopts "h:r:" optionName; do

                case "$optionName" in

                h) TARGET_LIST=$OPTARG;;

                r) RETENTION_DAYS=$OPTARG;;

                esac

                done

                 

                 

                for TARGET in $TARGET_LIST

                      do

                            STAGEDIR=" "

                            blcli_execute Server getFullyResolvedPropertyValue $TARGET STAGING_DIR

                            blcli_storeenv STAGEDIR

                            [[ -z $(echo $STAGEDIR | grep /stage$) ]] && {

                                  echo "$TARGET STAGING_DIR does not end with /stage, agent cleanup aborting" >&2

                                  } || {

                                  blcli -n false Delete cleanupAgent $TARGET $RETENTION_DAYS

                                  }  

                      done

                1 of 1 people found this helpful
                • 6. Re: Server Cleanup Script and the cleanupAgent BLCLI
                  Tal Abramson

                  Thank you , all my server have the same staging setting

                  But now i can see a different issue with this BLCLI

                  i tough it will clean my Transaction folder as well using the default location

                  I have to set the TRANSACTIONS_DIR property even if i am using the default location ?

                  • 7. Re: Server Cleanup Script and the cleanupAgent BLCLI
                    Mike Jones

                    You don't need to set the TRANSACTIONS_DIR property for the transaction folder to be cleaned up

                     

                    The reason for the wrapper script is that the cleanupAgent blcli command reads the STAGING_DIR property and cleans that up, you can run it directly but although unlikely if the STAGING_DIR property gets set incorrectly it cleans from there and if you have a scheduled task to cleanup the agent .....

                     

                    If you want to try it ON TEST VM YOU CAN REBUILD set the  STAGING_DIR to /Windows or /opt and run the cleanupAgent command.

                     

                    Although your question has made me think about another test and a change to my wrapper script.to see if the same is true if the TRANSACTIONS_DIR is accidently set to the wrong location