Am 01.02.2012 um 19:45 schrieb Lane Schwartz:

> On Wed, Feb 1, 2012 at 1:32 PM, Rayson Ho <[email protected]> wrote:
>> If you want to get the same behavior as your GE 6.2u6 cluster, then I
>> think bash should be taken out from the login_shells.
>> 
>> I look a 5 min look at the code, and I think currently there is no way
>> to do what you want - so best way is to fix the bash profile and/or
>> change the SGE config.
>> 
>> BTW, what's in the bash profile that is causing this random job start
>> directory problem??
> 
> Thanks for the info. I now have a solution to the problem.
> 
> When I ssh in to a machine I like to be directly cd'd to whatever
> directory I was in the last time I was logged in to that machine. To
> accomplish this, I have a function defined in my .bashrc overriding
> exit:
> 
> function exit { mkdir -p $HOME/.path_history; pwd >
> $HOME/.path_history/host.$HOSTNAME; builtin exit; }

NB there is also a .bash_logout or the option to trap the exit event (it's 
handled like signal 0):

trap 'mkdir -p $HOME/.path_history; pwd > $HOME/.path_history/host.$HOSTNAME' 
exit

-- Reuti


> So when I type "exit" at the shell, this function records the
> directory that I'm exiting and stores that info in a host-specific
> file ($HOME/.path_history/host.$HOSTNAME)
> 
> In my .bash_profile, I then check to see if that file exists. If it
> does, the .bash_profile cd's me to the stored directory.
> 
> if [ -f $HOME/.path_history/host.$HOSTNAME ]; then
>    cd `cat $HOME/.path_history/host.$HOSTNAME`
> fi
> 
> For some of my hosts, the $HOME/.path_history/host.$HOSTNAME file was
> pointing to my home directory. So when a job started on those hosts,
> it would cd to my home dir. If I subsequently ssh'd in to that machine
> to try and debug the problem, when I exited the recorded directory
> would be reset, causing more apparent non-determinism.
> 
> To solve the problem, I have wrapped the above code in my
> .bash_profile to first check to see if I am in a grid job:
> 
> if [ -n "$JOB_ID" ]; then
>    # do stuff
> else
>    if [ -f $HOME/.path_history/host.$HOSTNAME ]; then
>        cd `cat $HOME/.path_history/host.$HOSTNAME`
>    fi
> fi
> 
> Thanks for the help debugging this! The problem now appears to be solved.
> 
> Cheers,
> Lane
> _______________________________________________
> users mailing list
> [email protected]
> https://gridengine.org/mailman/listinfo/users


_______________________________________________
users mailing list
[email protected]
https://gridengine.org/mailman/listinfo/users

Reply via email to