Reputation: 7852
I have the script on centos 7
server for kill process by used id:
#!/bin/sh
echo "killing services..."
kill -9 "$(lsof -t -i:3011)"
kill -9 "$(lsof -t -i:4011)"
Above script works fine when it is called from the server.
But my goal calls this file using ssh
from my local machine like:
ssh [email protected] "sh ~/stopServices.sh"
But I git this error:
killing services...
/home/system/gepick-dev/stopDevServices.sh: line 5: lsof: command not found
/home/system/gepick-dev/stopDevServices.sh: line 5: kill: `': not a pid or valid job spec
/home/system/gepick-dev/stopDevServices.sh: line 6: lsof: command not found
/home/system/gepick-dev/stopDevServices.sh: line 6: kill: `': not a pid or valid job spec
Upvotes: 0
Views: 451
Reputation: 18608
you need to install lsof on the remote server.
or try to add the full path like /usr/sbin/lsof to your script or configure your PATH in the remote server if the binary is already installed
Upvotes: 1