[torqueusers] login-scripts within mom
Garrick Staples
garrick at clusterresources.com
Thu Dec 7 13:51:54 MST 2006
On Thu, Dec 07, 2006 at 09:38:05PM +0100, Thomas Zeiser alleged:
> Hi Gerrick,
>
> On Thu, Dec 07, 2006 at 01:11:38PM -0700, Garrick Staples wrote:
> > > > >
> > > > > can I configure torque in a way that mom excecutes standard user
> > > > > login-scripts on each computenode before starting the job (non interactive)?
> > > >
> > > > Doesn't it already happen? The initial process is started as the user's
> > > > login shell.
> > >
> > > that's true -- but depending on how the mom is compiled (cf.
> > > http://www.clusterresources.com/pipermail/torqueusers/2006-October/004525.html)
> > > new shells may be forked to actually execute the job script. And
> > > these shells are no longer login shells (at least by default) and
> > > thus do not get definitions of aliases or shell functions as e.g.
> > > used by modulecmd.tcl ...
> >
> > You don't need a login shell to get aliases and shell functions, or else
> > you'd never be able to use them in a shell script.
>
> passing environment variables through is no problem - but I do not
> get aliases or shell functions passed through (and that's exactly
> what you need for e.g. module load xyz):
>
> unrz at woody1: 21:29 [~] > alias
> unrz at woody1: 21:29 [~] > echo $SHELL
> /bin/tcsh
> unrz at woody1: 21:29 [~] > alias xx
> unrz at woody1: 21:29 [~] > alias xx ls
> unrz at woody1: 21:29 [~] > alias xx
> ls
> unrz at woody1: 21:29 [~] > tcsh
> unrz at woody1: 21:29 [~] > alias xx
This is to be expected, functions aren't inheritable.
> unrz at woody1: 21:31 [~] > bash
> unrz at woody1:~> xx () { ls ; }
> unrz at woody1:~> set|tail -n 4
> xx ()
> {
> /bin/ls $LS_OPTIONS
> }
> unrz at woody1:~> bash
> unrz at woody1:~> set|grep xx
> unrz at woody1:~>
Same thing, you can't define a function in your shell and expect child
shells to see it.
> and of cource, >ssing aliases (or shell functions) from tcsh to
> bash/sh or vice versa does not work at all ...
>
> > Login shells get you the initial set of environmental variables. Since
> > they are exportable, they should only be setup once.
Your functions need to be defined in your shell's rc scripts, eg.
~/.bashrc. *not* in your profile (that is only sourced at login).
More information about the torqueusers
mailing list