Reduce CPU time on AIX system

Posted on 2009-12-16
Last Modified: 2013-12-20

I need some help of writing a script file to be execute on AIX system.

Let me describe the situation and the problem.

I am having a program which will write a lot of messages to a database tables for every single database connection when user is doing any transaction. I could have many concurrent connections.  However, I have given user an option to write the message to a file on disk instead of to the database table if the program detects the existence of a script file (see the below) in the system. The problem is that the CPU usage was quite high (50% usage) if this option is available (i.e. the script file exist). Now, my question is how to (or if there is a way to) write messages to a memory and then write it to the file periodically (say every 5 minutes) instead of my script  (below) which write to the file for every message.  Thank you.

set -a
set -u

echo $@ >> /home/logs/systemlog.log;

exit 0
Question by:tommym121
    LVL 68

    Expert Comment

    are you able to determine what is actually causing the high CPU usage when the script is being called?
    It seems obviously so that running your script would cost much less CPU than writing to a database table.
    There must be some other problem (maybe in the program calling the script).
    Writing to memory only by means of a shell script is not really possible. The only way for a shell script (let aside languages like perl etc.where things should be different) is to create variables (e.g. arrays). But how would you flush their contents to disk in a consistent manner?
    Even if one could develop such a method, why would you think that it should cost less CPU time than your simple script?
    Try to find out where the CPU consumption really does result from. Use topas or nmon for that purpose. I bet that your script will not be the culprit!

    Author Comment


    Thank you for the comment.

    Actually, I did do an analysis of the cpu usage using vmstat. I also think that the problem is not
    on the script. Probably, it is not a problem at all. But, I have trouble to convince myself. The CPU usage is at about 40%. From the vmstat the wait time is 0%, user time is 12%, system time is 19%, remaing 69% is for the idle time. So, I think the cpu usage is actually good and that we are using the CPU Capacity. Am I right? I still do not know what causing the CPU Usage as the memory is okay and the page space used is very low so there is no memory swapping going on. There is also no i/O activities during the CPU surge.  Is there any good online document or link that we give me more insight on this cpu usage. I found a lot on the net but so far I have not found a single one to match what I am looking for.

    Any advice and guidance would be greatly appreciated.

    Thank you.
    LVL 68

    Accepted Solution


    all this doesn't sound really threatening. Your CPU usage values are just perfect - where are the 40% you mentioned in your comment?
    Did you try topas to analyze which processes are actually consuming the CPU?
    Or use nmon, whose output is a bit more meaningful.

    Maybe it's just the frequency of the calls to your script being responsible for some CPU consumption?
    You could check this frequency by counting the lines of your outputfile in regular intervals, like
    while true; do wc -l /home/logs/systemlog.log ; sleep 30 ; done

    If you don't have nmon already, it's here:

    I'm not aware of a single document to fit accurately to your problem.

    developerworks in general is a good resource:

    and here is a thing that could give you some hints:

    This is an AIX tuning overview (it's for AIX 6.1, but most things are valid for AIX 5, too):

    Please let me know what you achieved, I'll assist you further, if needed.


    Author Closing Comment

    Thank you for your help.

    Author Comment

    Thank you for your help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    Title # Comments Views Activity
    withoutTen challenge 14 67
    FizzBuzz challenge 9 63
    changeXy challenge 13 40
    check unix curl command return value 7 29
    Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
    Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now