Are there any documents available for checking the execution time taken by ksh commands?
My requirement is to fine tune a set of shell scripts having lot of "echos" and "date"s.
Is there a better replacement for the below code?.
echo "ABC process started on `date`"
some code..
echo "ABC process ended on `date`"
echo "BAC process started on `date`"
some code
echo "BAC process ended on `date`"
.......................
.......................
Thus it goes on...
These lines with very less difference is repeated more than 3000 times in my shell script.Please post any method by which I can reduce the execution time.
I guess your initial question was optimization of the script. In that case, without knowing what " process command " is doing, its not possible to provide suggestions on script optimization. Sorry if process optimization is not ur question
Sorry if I created any confusion here. I will explain my query.
I have these similar lines of code all through my korn shell script(my_script.sh). I have many shell scripts (ABC.sh,BAC.sh,CAC.sh,LKJ.sh,POI.sh and many hundreds) which is run through this parent shell script.
Below is my_script.sh:
echo "ABC.sh started at `date`"
sh ABC.sh
echo "ABC.sh ended at`date`"
echo "BAC.sh started at `date`"
sh BAC.sh
echo "BAC.sh ended at `date`"
.......................
.......................
Thus it goes on for other files too...
Can I reduce the execution time of my parent script by changing the echo command or date command? I have heard that cat is a better replacement for echo. But will it work in this case?
Probably you could try embedding these multiple commands into a perl script and make use of localtime() instead, so that you dont have to call date command 3000 times or more
If you are using cat, essentially you will have to push that to a file and display from that, am not sure why do you want to do that!!!
call get_date anytime you need a timestamp. You did not post anything else, but if you did the same bactic trick you could modify your coprocess.shl to give multiple responses
BTW - this still leaves one level of child process creation; every date call executes an image. bash has a feature that allows you to create native (i.e., linked into bash) functions in bash written in C, if I recall correctly. That would further improve things.