Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

.sh file usage log entries multiplied

Lars LindwallJun 24 2013 — edited Jun 28 2013

Hi all,

I have a very strange problem: In order to find out what parts of a big application being used,
I have added the following line as the first executable line in every .sh file:

/application/sh_log $0

The file sh_log looks like this:

now=$(date +"%Y_%m_%d")

filename=/spool/logs/sh_log_$now.log

if [ -f $filename ];                 # Does logfile exist?

then

   echo  $(basename $1)";"$(date +"%Y%m%d%H%M%S")";" >> $filename   # Logfile exists, append log record

else

   touch $filename          # Logfile did not exist, create it

   chmod 7777 $filename     # Make it writeable

   echo  $(basename $1)";"$(date +"%Y%m%d%H%M%S")";" >> $filename   # Ans append log record

fi

The application calls it's .sh files in a number of ways, but all of them originating from crontab.

What confuses me is that log entries often appear in tuples, that is, when the application's
.sh file is calling the file making the log entry, supposedly to make a single log entry, I'm still
getting 2, 3 or even more log entries with the same time-stamp (resolution: 1 sec).

I don't understand this and would appreciate if some guru here could give me a clou.

Regards

Lars

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 26 2013
Added on Jun 24 2013
2 comments
487 views