If your process can source whichever of /etc/profile
or /etc/bash.bashrc
and their respective $HOME
files, then this might work for you:
screen -d -m bash --init-file background-shell-script
When "background-shell-script" exits, the screen session will be sitting waiting for you at a shell prompt when you reattach with screen -r
. If you reattach before the process is complete, you will see whatever output it creates as it occurs and have a shell prompt when it finishes.
To source the normal startup files, add them at the beginning of your script:
. /etc/profile
# more source statements, if needed
# do your stuff here