Operating System - HP-UX
1752789 Members
5750 Online
108789 Solutions
New Discussion юеВ

Shell script execution slow

 
Sanjib Talukdar
Occasional Advisor

Shell script execution slow

All,

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.
Sanjib.
8 REPLIES 8
Con O'Kelly
Honored Contributor

Re: Shell script execution slow

Hi

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.

Cheers
Con
T G Manikandan
Honored Contributor

Re: Shell script execution slow

Can you post the shell script.

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

Muthukumar_5
Honored Contributor

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

Regards
Muthu
Easy to suggest when don't know about the problem!
Sanjay Kumar Suri
Honored Contributor

Re: Shell script execution slow

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

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
MarkSyder
Honored Contributor

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
Steve Steel
Honored Contributor

Re: Shell script execution slow

Hi

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)
Sanjib Talukdar
Occasional Advisor

Re: Shell script execution slow

All,
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.
Sanjib.
Bill Hassell
Honored Contributor

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.


Bill Hassell, sysadmin