How to automate tasks

Automation has always been the holy grail of information technology departments everywhere. Sysadmins and DBAs always prefer to automate the routine and boring tasks to make more time for interesting projects. Managers also like automation, mostly because this means fewer employees can do more work, and because automated tasks usually involve fewer human errors.

Some tasks are automated to a point where they run automatically at a specific time every day without DBA present. Backups are the most common example of this. More often the DBA writes a script that will automatically do what used to be a series of steps done manually by the DBA at some point, every DBA has the “create schema” script that will create a user with the permissions and objects he is going to need.

After years of automating different tasks, I’ve come up with a method of doing this which usually brings good results, and which I always regret when I don’t follow:

1. Automate the task after you did it manually at least three times. This gives you better understanding of the different scenarios you need to prepare for and also prevent you from wasting time automating tasks that turn out not to be routine after all.

2.  Write down all the steps you do when you perform the task manually. This helps when writing the script, and also serves as good documentation later on.

3. Write a script that does the task based on the steps you wrote earlier.

4. To verify that the script indeed does the right thing I run it in debug mode – step by step, verifying that each step behaves as expected. Step n  is supposed to shut down the listener, verify that after step n the listener is really down.

5. The script should output a log with all the action taken, responses and errors. You will need this when something goes wrong.

6. Run the script several times and verify the results and log.

7. Ask someone else to review the script with you. This can help catch bugs, make sure the script is readable to other people and have the added benefit of having someone else who can maintain the script if needed.

8. If you schedule it using cron, oracle job scheduler or a similar system, add a change to your change tracking system saying that this script now runs automatically every day at 3am.


2 Comments on “How to automate tasks”

  1. coskan says:

    Good point.

    In my opinion value of the DBA is appraised by amount of tasks he automated.
    And Good DBA is the one who just runs and monitors what he automated.

  2. prodlife says:

    Is it on your “invalid DBA” list? Should go there.
    “Invalid DBAs don’t automate tasks”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s