fhg
Volume 9, Number 14 -- April 22, 2009

Releasing File Member Locks With QSH

Published: April 22, 2009

by Tom Van Looy

Sometimes our users just keep their sessions open when they go home. At times, such as when we need to install software updates, this is a problem.

It is possible to write a CL that cleans up the file/member locks without getting too complicated? You'll be happy to know it is. Unix to the rescue! All you need is to quickly hack together a small nine-line QSH shell script to do the job.

See this example file named unlock that lives in my /home/tvl directory on the IFS:

for file in $@; do
system "WRKOBJLCK OBJ($file) OBJTYPE(*FILE) 
MBR(*ALL)" 2>/dev/null | grep HELD | cut -c 16-46 > /tmp/.jobs.tmp
while read lock; do
if [ `echo $lock | wc -c` -gt 1 ]; then
system "ENDJOB JOB(`echo $lock | cut -d " " -f 3`/`\
echo $lock | cut -d " " -f 2`/`\
echo $lock | cut -d " " -f 1`) OPTION(*IMMED) LOGLMT(0)" 2>&1 | \
grep -v CPC2206 | grep -v CPC1230
fi
done < /tmp/.jobs.tmp
rm /tmp/.jobs.tmp
done

This script can be called from IBM i with:

QSH CMD('sh /home/tvl/unlock FILE1 FILE2 FILE3 FILEn')

Or, you can feed it the result of a file list:

QSH CMD('sh /home/tvl/unlock `cat /home/tvl/files`')

Or, even feed the result of a DB2/400 SQL query. For example:

QSH CMD('sh /home/tvl/unlock `db2 "select name from allfiles where changed=1"`')

The script will, for every file, first collect jobs that have a file/member lock on the object and output the job details into a temporary file. Next, the script will *IMMED end the job that is holding the lock. The two messages that I am ignoring are:

CPC2206 - Ownership of object QZSHSYSTEM in QTEMP type *USRSPC changed
CPC1230 - LOGLMT changed for job

Using QSH makes quick system administration jobs easy. No compiling needed, just use the power of a Unix shell.


Tom Van Looy started out his IT career as an ILE/RPG developer in 2005 and moved over to the position of i5/OS system engineer in 2007. Although a Unix enthusiast, he also has great affinity with GNU/Linux and *BSD. Send your questions or comments for Tom to Ted Holt via the IT Jungle Contact page.




                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot


Sponsored By
PROFOUND LOGIC SOFTWARE


Now is the time to take control of your
application modernization.

You may have already tried or looked at
various solutions and methods. If you have not
achieved phenomenal results in record time, you
must attend one of our webinars.

Register today and see the difference.



Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Edwin Earley, Brian Kelly, Michael Sansoterra
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

Essex Technology Group:  AS/400 to Power & Beyond Roadshow with Dr. Frank Soltis, May 18-21
Halcyon Software:  Do more with less resource with Message Management
COMMON:  Join us at the 2009 annual meeting and expo, April 26-30, Reno, Nevada


 

IT Jungle Store Top Book Picks

Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
The iSeries Express Web Implementer's Guide: List Price, $49.95
The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
The System i Pocket RPG & RPG IV Guide: List Price, $69.95
The iSeries Pocket Database Guide: List Price, $59.00
The iSeries Pocket SQL Guide: List Price, $59.00
The iSeries Pocket Query Guide: List Price, $49.00
The iSeries Pocket WebFacing Primer: List Price, $39.00
Migrating to WebSphere Express for iSeries: List Price, $49.00
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
Can the AS/400 Survive IBM?: List Price, $49.00
Chip Wars: List Price, $29.95


 
The Four Hundred
The State of PHP on the Power Systems i

IBM Tweaks Some i Deals, Nukes Some Old i Tools

Come On Out, Power6+, You Win

As I See It: Berry Berry Annoying

First Quarter Sees Largest Tech Job Losses Since 2002

Four Hundred Stuff
Nimsoft Delivers Business View of IT with BSM Express

Telephony Application Integrates with PBX Today and VoIP Tomorrow

Falconstor VTL Drives Efficiency into System i Backups

Spell/400 Provides a Green-Screen Spell Checker

VAI Offers Panasonic Toughbooks to ERP Customers

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

System i PTF Guide
April 18, 2009: Volume 11, Number 16

April 11, 2009: Volume 11, Number 15

April 4, 2009: Volume 11, Number 14

March 28, 2009: Volume 11, Number 13

March 21, 2009: Volume 11, Number 12

March 14, 2009: Volume 11, Number 11

TPM at The Register
Canonical punts Ubuntu Jaunty Jackalope

King Larry launches Oracle-Sun combo at Big Blue, Cisco

HP pits Matrix against Cisco's California

Microsoft puts Sun's Tremblay in SiArch

HP goes sweet sixteen with HP-UX 11i update

BNT and IBM discover patent love to block Unified Cisco

Dell chases Sparc shops with migration offer

IDC: Linux to benefit from recession

IBM-free Sun unwraps Nehalem EP servers

Big-iron brains powers Schooner appliance power

Dell adds VC hotshot to board

IBM serves System S streaming super

Sun software - Does it make diddly?

Nehalem aces OLTP test on HP iron

THIS ISSUE SPONSORED BY:

WorksRight Software
Profound Logic Software
Halcyon Software


Printer Friendly Version


TABLE OF CONTENTS
Don't Ignore the View

Releasing File Member Locks With QSH

Trouble-Shooting i5/OS Printer Problems in a Warehouse Environment

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
PHP CLI Call

Perl, PHP, and/or ZendCore

batch printing PDF files from RPG program

Using db2_connect in PHP on iSeries

How to return value from CL program?

ADO.NET/IBM.Data.DB2.iSeries/ iDB2Connection

Order by alias names




 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2009 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement