Naming Conflict Generating Log Files

My database team supports approximately 70 software developers.  We have inherited many database maintenance utility scripts, that automate several routine database activities.  In our dynamic software development environment we all developers to choose the version of the database schema to run their code against.  

Our development environment is a unix variant, i.e. Oracle Solaris.  When developers install new versions of the application they must associate the correct version of the database schema.  So our team has devised a script to handle this chore for each developer.  The problem is this script generates a log file and the naming of this log files sometimes gets missed name with a previous version.  

Log file mechanics:

•      Log file is named same as script being run
o      Log file name is identical to script with a “g” plus number extension
o      Example:  script=DumpRecord logfile=DumpRecord.g1
•      Print all current active variables
•      Print all echo statements in script


This database utility script is run at a high rate of frequency almost concurrently by some users.  The script allows J2EE software developers to update their individual schemas to run against their application in their isolated environment.  Developers are separated by Oracle Solaris Zones, however supported by a single database.  

Any ideas to avoid naming conflicts?
LVL 1
sdrussAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Perhaps include the user id as part of the log file name?  

And add a date / time stamp with enough precision to avoid collisions?

Is there any utility or control mechanism they use to submit these scripts to be run, if so does that tool assign each request any kind of a unique identifier that could be used in the log name?

Just a few thoughts...


»bp
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Likely best to use the lockfile-progs code.

apt-get install lockfile-progs (or equivalent)

Open in new window


Then refer to man page for usage.

Summary: You first call lockfile-create before you begin writing to any log file, to create an associated lockfile. If this operation fails, then some other program has already created a lock file, so you'd then just generate a new log file name + try again... looping until you have a free logfile.

And this may result in log files produced which are difficult to access by name later.

Likely best if you open a Gig for this + have someone walk through your code + suggest refinements to avoid collisions.

Bill's suggest of simply adding timestamp my be sufficient.
0
sdrussAuthor Commented:
UserId is a non-starter as developers all run as the same generic application user.  Based on review it looks date/timestamp with precision was once attempted and now commented out of the script.
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

sdrussAuthor Commented:
lockfile-create viable for Solais-11 bash environment?
0
sdrussAuthor Commented:
Help!!!

So what is the best method for creating a uniquely name log file name in a Solaris bash environment, based on my above requirements?

Again the current method has a proprietary script (from a former employee) that generates log files, based on the script name with a ".g[sequential number]" extension.

    So, for example script named ReOrgIndexes, would generate a log file named ReOrgIndexes.g1.  And the second and third, etc. invocations of the script would likewise generate log files named:  ReOrgIndexes.g2,  
                                                                          ReOrgIndexes.g3,  
                                                                          ReOrgIndexes.g4

What is the best method based on my requirements to avoid log file naming conflict:

            1.  Use of mktemp or tempfile utility
            2.  Add date/timestamp with enough precision
            3.  Use $RANDOM bash shell variable
            4.  Use of $$ variable
0
Bill PrewIT / Software Engineering ConsultantCommented:
Not to belabor the point, but given this statement it feels like the script should have access to the userid someplace, no?
The script allows J2EE software developers to update their individual schemas to run against their application in their isolated environment.

»bp
0
sdrussAuthor Commented:
Developer's all run the application logged in as the same user.  We have established a group account, and this is possible become we all have our own zone. Development environment runs on Solaris zones.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Bash

From novice to tech pro — start learning today.