Welcome to WebmasterWorld Guest from 54.144.107.83

Forum Moderators: bakedjake

Message Too Old, No Replies

Run a Command and Exit SSH

     
2:52 pm on Jan 3, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:July 22, 2005
posts:180
votes: 0


Hello,

I login to the server over SSH.

I am looking for a way that would allow me to run a command and then be able to exit SSH.

$ php script.php

The ampersand after the command does not work. The command goes into the background allright. However, the command terminates after I close the SSH window.

Any ideas and tips appreciated.

Thanks.

4:19 pm on Jan 3, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 1, 2003
posts:815
votes: 0


You can try using the screen command.

[rackaid.com ]

6:47 pm on Jan 3, 2008 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2886
votes: 1


You can use the nohup (no hangup) command for this.

For example:

nohup php script.php &

Output and error messages are automatically placed in the file nohup.out in the current directory.

5:02 pm on Jan 4, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member wheel is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 11, 2003
posts:5063
votes: 11


I use the screen command myself in this situation.