• 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
    Midrange Dynamics North America

    Git up to speed with MDChange!

    Git can be lightning-fast when dealing with just a few hundred items in a repository. But when dealing with tens of thousands of items, transaction wait times can take minutes.

    MDChange offers an elegant solution that enables you to work efficiently any size Git repository while making your Git experience seamless and highly responsive.

    Learn more.

    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

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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