Popular Posts

Feb 26, 2018

How to create a cron job using script without editor

How to create a cron job using script without editor 

APPLIES TO : cron job modification

GOAL : This document explains how to add any cronjobs by using a script without open the corntab in editor. 


SOLUTION : Create a script with like below, modify the cron job as per your environment requirement, execute the script to perform the modification.

            #!/usr/bin/ksh
            #write out current crontab
            crontab -l > /tmp/mycron
            
            #echo new cron into cron file
            echo '* * * * * uname >> /tmp/cron.out' >> /tmp/mycron
            echo '* * * * * date >> /tmp/cron.out1' >> /tmp/mycron
            
            #install new cron file
            crontab /tmp/mycron

            rm /tmp/mycron


Cron line explanation  


        1. The number of minutes after the hour (0 to 59) 

        2. The hour in military time (24 hour) format (0 to 23) 
        3. The day of the month (1 to 31) 
        4. The month (1 to 12) 
        5. The day of the week(0 or 7 is Sun, or use name) 
        6. The command to be executed. 

* * * * * "command to be executed"
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)




~Judi~

Feb 22, 2018

NSH script to change list of servers description - blcli

BMC BladeLogic - NSH script to change server description or property value of servers - setPropertyValueByName - blcli 

APPLIES TO : BMC Server Automation 8.8

GOAL : This document explains how to change the description of a list of servers using blcli command without login to Bladelogic console.

SOLUTION : Create a NSH script to execute against the list of servers. Find the NSH script below, Before executing the script we need to set the profile option, role name, and acquire the BBSA credentials.


1.    Set Profile Name
               blcli_setoption serviceProfileName "Production Domain"

2.    Set Role Name
               blcli_setoption roleName BLAdmins

3.    Acquire credentials
               blcred cred -acquire
               Production Domain
               judi@mycompany.com
               <enter the credentials>

4.    Update the server list in a file named server_list
5.    Create NSH script named description_change.nsh with the below content 

          #!/app/bmc/bladelogic/appserver/NSH/bin/nsh
          >fail
          >pass
          for ServerName in `cat server_list` ; do
           RESULT=`blcli -t BLSSO -v "Production  Domain" -r BLAdmins Server setPropertyValueByName $ServerName DESCRIPTION "Unix Servers"`
           if [ $? -ne 0 ] ; then
           echo "$ServerName - $RESULT" >> fail
           else
           echo echo "$ServerName - $RESULT" >> pass
           fi
          done

6.    Log Files: 
               Pass - Contains the list of servers description changed successfully.
               Fail  Contains the list of servers description NOT changed successfully.




~Judi~

               

Popular Posts