0

I am sshing to my remote CentOS 5 server and want to run a script that takes long time. How can I have it keep running even after I close ssh session?

2 Answers2

3

You can use nohup in conjunction with & like this:

nohup ./m_script.sh &

The magic of nohup is that it allows a process to run even if your connection to the machine is gone. Meaning you logged out or are even disconnected. The & at the end means the process should run as a background process.

So when you enter that command the combo of nohup and & assures you that after you logout the process will still be running on the server.

Giacomo1968
  • 58,727
2

Use a program such as Screen.

Start a screen with Screen -S "name", resume it with screen -x

Jon
  • 9,479
  • 40
  • 99
  • 131