• 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:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Tags:

    Sponsored by
    Lightedge

    Your IBM Power Cloud Strategy Should Start With “Why?”

    Moving IBM i to the cloud isn’t just an infrastructure decision.

    A hardware refresh, data center exit, IBM i skills gap, disaster recovery requirement, or broader cloud initiative can each lead to a very different architecture.

    At Lightedge, we start by understanding what you’re trying to accomplish. Then we look at the workload, application dependencies, resiliency requirements, operating model, and long-term strategy to determine where that workload belongs.

    Managed IBM Power cloud? IBM Power Virtual Server? DR in the cloud? A hybrid architecture connecting IBM Power with AWS or Azure?

    There isn’t one right answer for every IBM i environment.

    Start with the business requirement. Understand the workload. Then decide where it belongs.

    Explore IBM Power cloud, managed services, and hybrid solutions from Lightedge.

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) 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

    Don’t Ignore the View Trouble-Shooting i5/OS Printer Problems in a Warehouse Environment

    Leave a ReplyCancel 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

  • PHP’s Evolution On The IBM i Platform Continues
  • Protecting IBM i Data For The AI Revolution
  • Guru: Two More Small But Handy RPG Enhancements: LIKE(*EXT) And %LOOKUPNE
  • IBM i Integration Gives Costco Shoppers Real-Time Inventory
  • IBM i PTF Guide, Volume 28, Number 33
  • IBM “Price Harmonization” Increases For Power Systems Coming In The New Year
  • Code For i Continues To Grow. Here Is What’s New
  • PowerSC: Your One-Stop Shop For Security On IBM i – And Beyond
  • As I See It: You’ve Been Flocked
  • IBM i PTF Guide, Volume 28, Number 32

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