0

The purpose of this exercise is to dump the output of ps sorted by command.

While the system is running we wish to dump all the running process sorted by command in a file.

There is a sort option in Linux like below.

ps -ef --sort -comm | grep -v grep | grep java > /tmp/preboot.log

After the server reboots and all the processes started afresh I wish to again dump the output like below.

ps -ef --sort -comm | grep -v grep | grep java > /tmp/postboot.log

Using diff /tmp/preboot.log /tmp/postboot.log we can be sure that all processes have been started alright is no difference is found..

The above works in Linux and does not work in Solaris.

Please suggest any solution for my requirement of pre & post reboot check for the process for Solaris.

2
  • What part of it doesn't work? Also don't you have to grep -v grep after the grep for java? But you could also just grep [j]ava to avoid that altogether. – jesse_b Feb 19 at 13:03
  • Solaris doesn't have gnu tools so the --sort option will not be available. You could probably just pipe to sort instead. – jesse_b Feb 19 at 13:04
0

I don't know if Solaris have it, and if have it how it behave, but on linux sort command work.

You can use sort command like this:

# With ps --sort
ps U $USER -o comm,pid --sort pid | head -n1
systemd 2120

# With sort cmd
ps U $USER -o comm,pid | sort -k2 | head -n1
systemd 2120

In my linux box it work.

i can't test on solaris

2
  • does not work on solaris. Output: $ ps U $USER -o comm,pid | sort -k2 | head -n1 ps: too many arguments usage: ps [ -aceglnrSuUvwx ] [ -t term ] [ num ] – Ashar Feb 21 at 3:16
  • Of course, is just an example. The key point is that if you have sort cmd on your solaris you can use it without call sort function of ps. Use somthing like: ps -ef -comm | grep -v grep | sort Be sure to use sort on the desired column – YetAnotherUser Feb 21 at 17:23

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.