在同一个VPS上使用php的exec ssh文件

I'm trying to launch a ssh file via php on same VPS, and I've had some problems with this.

When I connect to VPS via Putty screen "nosaukums" doesn't show in screen list, but all is working with sh file launching.

exec('cd /home/galvena/gameserveris ; screen -dmS nosaukums sh start.sh);

What could be wrong?

I have a second question. When I try to turn off a screen via php I get the error

Must be connected to a terminal

when trying to execute the following:

exec('cd /home/galvena/gameserveris ; screen -r nosaukums ; stop');

I dont see the reason of running this deamon in another screen. What you can do instead is create a simple shell script in the init.d folder with stop and start commands as you already have them. Then from php you can just call something like system('service your_service_name stop/start'); Example of such script for a java solr deamon can be seen here: http://rc98.net/solrinit

You can also use ps -aux | grep nosaukums to check if its running. I am pretty sure also you can get the pid of that service with a unix command which unfortunately i dont know, but some googling will def show it and then just run exec('kill PID');

That just of the top of my head. Hope it helps...

Note the service command might require root priviledges so you may just put the script elsewhere and run it manually or just implement it directly in php...