I have written a shell script named startup.sh which does a lot of things (basically start a lot of things for me after turning on my local machine) - here is an excerpt:

gnome-terminal --tab &
veracrypt --auto-mount favorites &
thunderbird &
~/Application/IDEA/bin/./idea.sh &
/usr/bin/slack &
echo myuser mypass | skypeforlinux --pipelogin &
sh bsync-project-folder.sh &

Open a console window and do:

. startup.sh

The shell script is executed and the window is closed afterwards.

Also working:

sh startup.sh



The shell script is executed and the terminal window stays open - however it does not return to the console and have to stop script execution with CTRL + C (no matter if I execute with the command line interpreter or with ./).

However I want a clean exit of my script and then return to the same console with a success message. What am I missing?

marked as duplicate by schily, Archemar, elbarna, G-Man, RalfFriedl Nov 15 '18 at 7:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


When you start a script with '< dot> < space> < script_name>' and you have in your script "exit", your window will be closed. The dot notation means you run it within the window and then the "exit" means to exit the window, not the script itself.
Try to add >/dev/null 2>&1 to each of the line (before final &) to find out which of the commands still holds stdout, eg.:
gnome-terminal --tab >/dev/null 2>&1 &
you may but need not to leave the exit at the end but it does not have any sense here. Run the script: ./startup.sh

  • With >/dev/null 2>&1 it turned out that intellij AND the second shell script were responsible for the script not to terminate properly. Thanks! – Blackbam Nov 14 '18 at 15:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.