2

I want to get a list of processes running on my EC2 instance(Linux, windows or whatever) using a script.

I researched a bit and got to know I will have to install SSM agent on my instance and then create document containing command to list processes. Document contain "content" field but how do I insert ps -A command in content? It's all too confusing?

I also want to know that is it possible using creating a SSH connection to my instance and log in to instance all in a single script?

Kamal Panhwar
  • 2,345
  • 3
  • 21
  • 37
ahmer
  • 25
  • 1
  • 1
  • 6

1 Answers1

3

Yes, you can get a list of processes running on your EC2 instance. You don't need to create a new document to do that. You're looking for the send-command. The easiest way to figure out how to do it is to use the AWS SSM console to execute the command through the console, and it will give you the command to run on the command line to repeat it.

You can also execute a command through SSH. That command would be:

ssh -i mykey.pem ec2-user@<insert your machine's IP address> "ps -A"

Essentially just enter the command after your regular SSH command.

Ryan Shillington
  • 23,006
  • 14
  • 93
  • 108