Stopping program on server from ssh client

I have a Linux server that I control through ssh client Putty while Working on Windows machine. I'm ready to upload an application to my server, however I need to figure out one thing first.

When I write a console program for Windows to terminate it all I need is to close console terminal. The program that I'm going to upload to my server has an infinite loop so it won't stop on its own. How am I going to stop it through ssh client? I suppose if I simply close ssh client the program will just keep hanging on my server. There's no gui, so no "X" button to press. So, how to stop it?
That depends on how you started it. If you have it running in the background it will probably keep running. The way to stop it is to find its process id and then kill the process:


1
2
3

ps -e | grep myprogram


That will return a string of information that will contain your program's process id - e.g.:

1
2
3
4

clint-> ps -e | grep myprogram
     8308    6048    8308       4788  con 205411 10:30:00 /home/clint/myprogram


The first field, 8308 is the process id of your program. You kill it with this:

1
2
3

kill -9 8308


This is just basic information -- there are lots of other issues that you might face if you have your program starting in cron or inittab.
Topic archived. No new replies allowed.