• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Releasing File Member Locks With QSH

    April 22, 2009 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

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    OCEAN User Group

    OCEAN TechCon25 Online

    It’s an Exciting Time for IBM i !

    July 16 & 17, 2025 – ONLINE

    Two virtual days of learning, presented by an outstanding group of IBM’ers and IBM Champions, featuring leading-edge topics.

    FREE for OCEAN members!

    Register NOW!

    Annual (12-month) Individual OCEAN Memberships are $80 and a Corporate Membership is $250. A Corporate Membership would allow your entire company to have full access to the OCEAN website & video library and to attend OCEAN events at member rates. Act now because rates are increasing on August 1, 2025.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    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

    DataDirect Updates ODBC Drivers IBM Launches Power6+ Servers–Again

    Leave a Reply Cancel reply

Volume 9, Number 14 -- April 22, 2009
THIS ISSUE SPONSORED BY:

WorksRight Software
Profound Logic Software
Halcyon Software

Table of Contents

  • Don’t Ignore the View
  • Releasing File Member Locks With QSH
  • Trouble-Shooting i5/OS Printer Problems in a Warehouse Environment

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle