0

On my remote Amazon EC2 instance, I've scheduled a Cron job to run a program once every hour. The program takes about 55 minutes to run, and sends me an email when it starts and when it stops.

It has been working well, but recently it seems as if the programs have abruptly began taking longer ('end email' arrives well over 55 minutes after start email). This also means potentially multiple processes are being run at the same time. I would like to confirm this by viewing all current processes being run - but for some reason, when I type 'ps' only two processes are shown: bash, and the ps command itself.

Any idea why the processes aren't being shown in ps? How can I find them? Once again, I'm SSHing into my Amazon EC2 instance - not sure if that's affecting which processes show up.

Thanks so much!

  • Are you typing ps with no options? By default, that will list only processes associated with the current terminal. To see all processes, you will need something like ps -e or (BSD-style) ps ax – steeldriver Oct 14 '17 at 17:00
  • Yes- that ended up being the issue! I thought ps would show all processes. The solution that ended up working was ps -eo pid,comm,cmd,start,etime - which showed all my processes, the process id's and the start time and how long the had been running. This allowed me to clearly identify processes which had been running too long and had to be killed. – doodeecheng5 Oct 15 '17 at 1:53
1

You have to use some flags to display all the processes, including the ones launched in the background by root, for example ps aux , and grep your process name.

  • -a : Display information about other users' processes as well as your own
  • -u : Display the processes belonging to the specified usernames

Check man ps for more information.

1

As suggested by the other users, I needed to add more details to my ps command. What ended up working for me was:

ps -eo pid,comm,cmd,start,etime

This showed all processes (-e) and gave the information I specified (-o): the process id (pid) so I could kill the task, the command (comm) - i.e. python, bash, etc., the cmd (the full path to the program), the start time, and the elapsed time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.