I'm trying to invoke a program to run on startup in /etc/rc.local which runs two commands:
- Start a detatched screen using
screen -dmS name
- Send a command to that screen using
screen -S name -X stuff command
However the command relies on environmental variablesbeing set. I've set these EXPORT commands in both the root .profile and the root .pam_environment file. For reference they are:
export PATH=$PATH:/usr/local/cuda-7.0/bin
export LD_LIBRARY_PATH=:/usr/local/cuda-7.0/lib64
However the started screen cannot see these variables and errors out with error while loading shared libraries: libcudart.so.7.0: cannot open shared object file: No such file or directory
- which is what I'd expect if these variables weren't set.
The trouble is I can't figure out why they're not set. My best guess is that, for some reason, the screen is using /bin/sh
(which is what it reports if I echo $0
, whereas the root's default shell is /bin/bash
The weirder thing is that this only happens for a screen instantiated like this at boot. If I use the same command to start a detached screen it all works correctly (and uses /bin/bash) with no problems with environmental variables.
Any idea what is causing this and how to fix? I'm using Ubuntu 14.04 LTS
.