Home > other >  Command should keep running in terminal after closing it
Command should keep running in terminal after closing it

Time:08-24

Sorry if this already asked.

I am pretty new in linux. I am trying to run some commands and script in terminal on CentOS, but when I close terminal my script stop working. Is there any why that script keeps running in terminal after closing it.

I have tried many of solution available online but no luck. Please! help.

Thanks!

CodePudding user response:

Have you treid tmux? If not you can run following commands and see if that helps you out.

First open terminal and install tmux on CentOS.

yum install tmux

After that create a session.

tmux new-session -d -s session_name

Change session_name to whatever you want to put name of session. A new session will be created. You can run your script and close terminal. It'll keep running on server.

If you want to access that session just run this command.

tmux attach -d -t session_name

You can list all sessions with command tmux ls.

Please! let us know if that works for you?

Thanks

CodePudding user response:

You have to use the nohup command in the following way:

nohup your_command &

It detaches the process you launched from the terminal itsel.

  • Related