I have to create shell script being myself real novice in scripting...
I was looking on the Internet for some script examples, but I don't have the basic understanding of the shell. I was trying to do something with �ps� command without success.
For exemple total number of running process: ps ax | wc -l | tr -d ""
Executed from command line work nice, but once in the script like echo �ps ax | wc -l | tr -d ""' return 1 which is not the right number of running process.
The script should do the following:
Should check the running processes
Display top five process (per cpu consumption)
output the summary for:
[list]
total number of processes
number of process per user
most common process
[/list]
ex.: process1
process2
process3
process1
result : process1
Is it too difficult to implement in pure bash script?
Thanks for your answer.
Server is running on ubuntu.
When I type the command in command prompt it format the output correctly. When executed from script like :
echo `UNIX95= ps -eo pcpu,pid,user,args | sort -r | head -5`
the output is formated in one line like this:
%CPU PID USER COMMAND 0.1 5162 root sshd: root@pts/1 0.0 7 root [khelper] 0.0 6 root [events/0] 0.0 5 root [watchdog/0]
Is there any formatting option or should'nt I use "echo"?