Sum using awk

Sum a column of file sizes output from an ls command using awk:

# ls -l *.iso | awk '{ SUM += $5} END { print SUM/1024/1024 }'

the below command will show you amount of memory used by apache :

# ps -ylC httpd --sort:rss | awk '{ SUM += $8 } END { print SUM/1024 }'

VMware ESX, killing a virtual machine that won’t die !

Sometimes the Virtual Center won’t do the job. You virtual machine has hung and you need to kill it. Here are 2 examples of how you can kill the vm from within the service console:

1. The ‘VMWARE-CMD’ command

* Log on to the service console and issue the following command ‘vmware-cmd /vmfs/volumes///.vmx stop’ you must not use the friendly datastore name. If you need to know the location of all vm’s type ‘VMWARE-CMD -l’ that will list on vm’s and the location for the corresponding vmx file.
* If that fails, then try it with the hard option, ‘vmware-cmd /vmfs/volumes///.vmx stop hard’ this command will just try and kill it without shutting it down.

2. Kill it using the PID command

* Run the following command: ps auxfww | grep to locate the correct PID of the virtual machine, the first number to appear in the output is your vm’s PID. Use the PID number to terminate the process by issuing kill -9