Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding a window when opening it from bash script

Tags:

bash

I am trying to make a bash script to run another bash script in a new terminal window.

I used the command:

sudo gnome-terminal -e "bash file_name.sh"

This works as I want it to. But I want to hide the second terminal window that opens. I have tried running in background using & but it does not work like I want it to. I want the terminal window to be hidden.

Is there any way I could set the terminal window to not show up?

like image 404
Anubhabchak Avatar asked Sep 02 '25 03:09

Anubhabchak


2 Answers

Well for what i have understood about Linux and the "&" optional command, it's already that what you call hidden. You may miss "disown" command so you can run the code in background while being able to close the shell.

start it in the background:

command &

then run:

disown

and close the terminal.

You can stop a foregrounded application with Ctrl+z, then start it in the background (foreground) with the bg (fg) command.

You can read the source here on a Ubuntu Forum: "How to hide terminal window?"

like image 157
harryIT Avatar answered Sep 05 '25 01:09

harryIT


You could use nohup to run the process in background:

$ sudo nohup ./file_name.sh &

There will be a new process to execute file_name.sh, output will be written to nohup.out.

like image 35
Thomas Raffelsieper Avatar answered Sep 04 '25 23:09

Thomas Raffelsieper