File in use crashed the backup CPF3156 - How to find what held the file open


See screenshot - a file was open and inuse while the backup was running and it failed.
As part of the backup we stop qinter and qbatch so no one can login.

Is there anyway of finding what held the file open during the backup.

Tks, Joe
Who is Participating?
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.

Check the job log of the backup for more messages that might explain the problem. The object is in use and the job log may say what job had the object locked.

For example, CPF32B3 would say something like this:

Message . . . . :   Cannot allocate object for file QCMDSRC in BLIB.          
Cause . . . . . :   The save operation was not performed for member CALC file
  QCMDSRC in library BLIB type *FILE, because it is allocated by job          
  069856/QSECOFR/QPADEV000G. Recovery  . . . :   Try the request again when  
  the object is available.                                                  

If you need more help, post back the job log!
Gary PattersonVP Technology / Senior Consultant Commented:
If QINTER an QBATCH were down, perhaps there was a server job that allowed a client program (using ODBC or JDBC for example) to access the file.  If the job is QZDASOINIT or QZDASSINIT, then that is what happened.  You probably want to end these type of host server jobs (and other problem services like FTP) during your backups as well.

- Gary Patterson
And note that QZDASxINIT server jobs may hold locks even after the client has finished. There might have been nothing actually going on at the time of the backup.

Use ENDHOSTSVR *DATABASE to end inactive database server jobs before backups begin and to prevent new connection requests. Then use STRHOSTSVR *DATABASE when backups are done. If you use the ENDACTCNN(*DATABASE) parameter for ENDHOSTSVR, then active connections will also be ended.

Use ENDHOSTSVR *FILE if you also want to backup IFS directories.

For the question, it might not be possible to learn what held the lock. The system history log might tell you something about what jobs were running. If you have job accounting active, more job detail would be available. If the file is journaled or if it is enabled for object auditing, either the file's journal or the system audit journal might give answers.

There are numerous possibilities; but without knowing what is configured on the system, there's no way to know what's available to you. If a feature hasn't been enabled, it won't log its info.


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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

MurpheyApplication ConsultantCommented:
What you can do (before starting the backup) is to claim the library by locking it exclusive.
 -  it will be locked and no program will be able to use it.
 - or if it returns with an error, one or more objects are in use.

When the library is in use, you can list what objects are invloved and whar jobs are locking these objects.
on that basis you can decide if you like to wait or kill the jobs.

joe90kaneAuthor Commented:
tliotta - Your suggestion of ENDHOSTSVR *DATABASE how would I implement this? I have the backup setup through the i Series navigator.
MurpheyApplication ConsultantCommented:
Hi Joe,

How do you stop your subsytems If QINTER, QBATCH and probably QCMN?
to do the backup the right way, I advice to write a CL program, to end the subsytems,
end the hostsrver, start the backup and at the end start everything again.

You can schedule that cl.

joe90kaneAuthor Commented:
Hi murphey2,

I totally new to CL programming, would you be able to guide me through setting this up or if there is a built in backup program that supports ENDHOSTSVR & STRHOSTSVR

Thanks, Joe
MurpheyApplication ConsultantCommented:
The easiest way to create CL's is via  PDM, cl is a language that is comparable with PC *.bat files, you can include a sequence of OS commands.
The big difference is that you can compile CL and you can prompt all commands.

You start your CL source with PGM and ends it with ENDPGM.

A CL to end the host server can look like this:




Open in new window

(You can also decide to end subsystem QSERVER )

After typing the command ENDHOSTSVR you can press F4 for prompting and use F1 on every field for detailed help text. There is syntax checking per line and the logic will be checked during compilation :-)
(Yes that is why OS400 is so much better then everything else)

Backup on the iSeries,
You can write a CL to backup every library like:




or an other option is with the RUNBACKUP command,
here you can predefine daily, weekly and monthly backupjobs, that can bestarted with only one command.

Just chek that with GO BACKUP

The complete CL should do the following:

End subsystems QBATCH, QINTER and (eventually) QSERVER and QCMN
Start the backup
Start the subsystems

Be sure that this job in not running in one of the subsystems that you will end.
I advice to use QCTL or make your own subsystem QBACKUP

If you know what you like to do, one of us will help you with the CL...


Gary PattersonVP Technology / Senior Consultant Commented:
A "restricted state backup" is the simplest and safest way to do a backup.  Basically, you end the system down to "single user" mode (ENDSBS *ALL from the console), and then run your backup.  GO SAVE, Option 21 is a full system backup that ends the system to a restricted state before performing the backup.  Of course, this means that no other work will be allowed to run on the system for the duration of the backup, but it also ensures that things like object locks don't occur.

After the backup completes, you STRSBS QCTL (or whatever your controlling subsystem is), and the system restarts, typically ready for users.

AS/400 backup, as with any complex multi-user system backup process, has some complexities that it is important to understand if you are responsible.  A backup that you cannot restore from isn't very valuable.  It is really important that you take the time to either train yourself, get trained, or have an experienced AS/400 backup expert help you get your backups set up properly.

The Backup and Recovery Guide for your OS version is a great resource, and you should take the time to familiarize yourself with it's contents.  It will answer a lot of your Backup and Recovery related questions.

Here's a link to the V5R4 manual:

- Gary Patterson
When someone is put in charge of maintaining backup procedures and has no experience with CL programming, the implication is that the site isn't particularly busy during off-hours. That isn't guaranteed, of course, but backup procedures can have a pretty complex relationship with applications that want to use files.

If the system is usually quiet during the backup timeframe, Gary's suggestion is probably a useful one. It tends to handle everything needed without extra programming. It's perhaps excessive in that it saves more than what's needed and in that it can use more media (more tapes or whatever). But it can also work when expertise doesn't exist yet.

Can you describe the general environment? How much DASD is in use? How much off-hours work does the system do? (Many hours of night jobs? Remote clients always doing work, e.g., SQL Server connections or web server?)

MurpheyApplication ConsultantCommented:
I agree, but most of the time (on production systems) you only like to backup the production files daily and not make a full backup of everything.
At the customer site I work now, all production files are backedup daily, all user libraries (program libraries) weekly and a total save monthly.. I think that's not too bad?


No, not bad at all -- it's what I prefer.

But then I'm comfortable with the exception-passing message model, the handling of server jobs and their connections and many other details of the system; I won't be climbing over obstacles that may arise from any one of the commands on any given night because I can code for them ahead of time. A new CL programmer whose job might be affected might instead choose to be conservative.

If the system is easily available for the processing and media is available for storage, I'm comfortable with it. It could even reduce the number of necessary decisions should a wide restore ever be needed. The point of backups is in the restores. Always having things in one package can be a blessing.

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
Operating Systems

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.