title: How to remotely kill a process on amazon EC2 linux instance
body: <p>I use Amazon EC2 instances to perform some complex computation by using the AWS Java SDK, these computations might take so long sometimes. Hence, I need to kill the process running on the EC2 instance remotely from my Java code so that I can reuse the same instance for another task without needing to stop and start the instance.</p>
  
  <p>The problem with stop and start, is that Amazon treat partial hours as complete hours, so my aim is to make my code more cost effective.</p>
  
  <p>I use SSH to connect with my EC2 instances and that is how I pass commands to be executed there. I doubt that if I disconnect the SSH connection and connect to it again, it would kill whatever process was running there. </p>
  
  <p>In short, what I need is away of doing Ctrl+C but from within my Java code (without user intervention). Is that possible?</p>
  
  <p>EDIT:
  To clarify, the computation is executed by a separate tool installed on the Linux EC2 instance. So I just pass the command to start this tool, then the command line waits until its finished and shows the results. On manual usage scenario, I can click Ctrl+C on linux command line and will get control of the command line back. But in my case, I want to do similar thing from java code if possible.</p>