Re: Shell script execution slow (567 Views)
Occasional Advisor
Posts: 15
Registered: ‎06-21-2004
Message 1 of 9 (567 Views)

Shell script execution slow


We have some shell scripts that take about couple of minutes to execute on HP UX 10.20. But the same shell scripts are taking more than 7 minutes to execute HP UX 11.00.

Are there any parameters (shell / kernel) that can affect the execution of time of scripts so much?
If there are how do they need to be configured?

Can there be any other reason for the slow execution of scripts?

The scripts are mainly searching for some log files using find command and looking for messages in those files using grep command.

Any help will be appreciated.

Thank You.
Honored Contributor
Posts: 645
Registered: ‎03-18-2003
Message 2 of 9 (567 Views)

Re: Shell script execution slow


If its using the find command then that probably explains the differences in execution time.

The larger the filesystem, the longer the find command will take to run. Try to limit the find to specific directories.

Honored Contributor
Posts: 5,532
Registered: ‎12-11-2000
Message 3 of 9 (567 Views)

Re: Shell script execution slow

Can you post the shell script.

Might be someone can point to new options with 'find' to execute better.

Honored Contributor
Posts: 4,030
Registered: ‎06-09-2004
Message 4 of 9 (567 Views)

Re: Shell script execution slow

To check the exact time performance the execute as,

time <scriptfile>

It will give the time taken by the script

Shell execution are depends upon the command and their environment and needs. Try to debug what your shell program doing as set -v or set -x (good)

Trace out what it is doing differently there.

Try to use effective logic's to use find / grep . Don't use cat logfile. Directly grep it or use < logfile.

It is good to have your shell script and time performance & debugging difference

Easy to suggest when don't know about the problem!
Honored Contributor
Posts: 1,063
Registered: ‎12-09-2003
Message 5 of 9 (567 Views)

Re: Shell script execution slow

Can you check the nice value which is used while executing these scripts?

A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Honored Contributor
Posts: 1,815
Registered: ‎11-10-2003
Message 6 of 9 (567 Views)

Re: Shell script execution slow

Does your HP-UX 11.00 box have NFS mounted filesystems? I have found out to my cost that these slow down the find command.

If so, try:

find / -fsonly hfs
and find / -fsonly vxfs

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Honored Contributor
Posts: 2,909
Registered: ‎02-13-2000
Message 7 of 9 (567 Views)

Re: Shell script execution slow


Certainly the find

Put your logfiles in fixed places and then no find needed over the whole system.

You can even use the ln command to
make 1 directory containing softlinks to all your log directories and only search via the start point with the -follow option

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Occasional Advisor
Posts: 15
Registered: ‎06-21-2004
Message 8 of 9 (567 Views)

Re: Shell script execution slow

Thank you for your replies and suggestions.
I do not think we have any issue with the file system because this script is part of the application that we are porting from HP UX 10.20 to HP UX 11.00 and it searches only in specific directories and only for specific files using the find command. The structure of the directory/file system is same on both HP UX 10.20 and HP UX 11.00 systems.
We will use the shell settings (set -x and/or set -v) to check the execution of the script to see if tells us anything.

Thank You.
Honored Contributor
Posts: 14,294
Registered: ‎05-29-2000
Message 9 of 9 (567 Views)

Re: Shell script execution slow

The shell is running full speed and will have virtually no differences between versions of HP-UX. As mentioned, it's the commands inside the shell that consume most of the time. By running with the -x option (ie, sh -x your_script or inserting set -x inside the script) you'll see the slow spots. Note that if the script is using functions, the -x option will be ignored during the time that the function is running. However, if you see those function calls pausing for a while, you can then trace just the function by inserting set -x inside the function.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.