Callum Kilby's Tutorials and Useful Code

Useful Code

krenewRun: running local jobs without your kerberos/AFS tokens either expiring or being lost

An issue when running jobs locally, particularly in a screen, is that kerberos and AFS tokens can either expire, or in the case of working on lxplus, will be cleared when you log off. To get around this, I use a script called krenew. This script generically allows you to start a daemon that copies your current tokens, and periodically refreshes them as desired.

I have made a wrapper for krenew, named krenewRun, to run any command line code passed in, with the tokens copied by krenew being refreshed until the process started by the command line code has finished running. This wrapper also performs a check for whether AKLOG is defined. aklog is the function that deals with AFS tokens, and AKLOG is the path to this function. krenew needs this function when handling your AFS tokens.

To make use of krenewRun, copy the below code into your ~/.bash_profile or ~/.bashrc. Usage is simply krenewRun "COMMAND", where COMMAND is whatever text you would have entered into your command line, with " marks escaped as \"

krenewRun( ) {
    if [ "$1" == "-h" ]
    then echo 'Usage: kenewRun "COMMAND"'
    else
        if [ -z $AKLOG ]
        then echo 'Please define AKLOG variable to be path to aklog (e.g. /usr/bin/aklog)"
        else
            krenew -t -- sh -c "$1"
        fi
    fi
}       

-- CallumKilby - 12 Apr 2016

Edit | Attach | Watch | Print version | History: r6 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...

Physics WebpagesRHUL WebpagesCampus Connect • Royal Holloway, University of London, Egham, Surrey TW20 0EX; Tel/Fax +44 (0)1784 434455/437520

Topic revision: r1 - 12 Apr 2016 - CallumKilby

 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RHUL Physics Department TWiki? Send feedback