This will show the amount of physical RAM that is left unused by the system. Show Sample Output
[ 2000 -ge "$(free -m | awk '/buffers.cache:/ {print $4}')" ] returns true if less than 2000 MB of RAM are available, so adjust this number to your needs. [ $(echo "$(uptime | awk '{print $10}' | sed -e 's/,$//' -e 's/,/./') >= $(grep -c ^processor /proc/cpuinfo)" | bc) -eq 1 ] returns true if the current machine load is at least equal to the number of CPUs. If either of the tests returns true we wait 10 seconds and check again. If both tests return false, i.e. 2GB are available and machine load falls below number of CPUs, we start our command and save it's output in a text file. The ( ( ... ) & ) construct lets the command run in background even if we log out. See http://www.commandlinefu.com/commands/view/3115/ .
I've wanted this for a long time, finally just sat down and came up with it. This shows you the sorted output of ps in a pretty format perfect for cron or startup scripts. You can sort by changing the k -vsz to k -pmem for example to sort by memory instead.
If you want a function, here's one from my http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
aa_top_ps(){ local T N=${1:-10};T=${2:-vsz}; ps wwo pid,user,group,vsize:8,size:8,sz:6,rss:6,pmem:7,pcpu:7,time:7,wchan,sched=,stat,flags,comm,args k -${T} -A|sed -u "/^ *PID/d;${N}q"; }
Show Sample Output
smem is very clever, it keeps in mind shared memory in its calculations!!! http://www.selenic.com/smem/ Show Sample Output
It repeats a command, such as free, every five seconds and highlights the differences
"That's it. Not much to see here. The first command writes any cache data that hasn't been written to the disk out to the disk. The second command tells the kernel to drop what's cached. Not much to it. This invalidates the write cache as well as the read cache, which is why we have the sync command first. Supposedly, it is possible to have some cached write data never make it to disk, so use it with caution, and NEVER do it on a production server. You could ... but why take the risk? As long as you are running a post 2.6.16 kernel,..." Source: http://ubuntuforums.org/showpost.php?p=3621283&postcount=1
Get the amount of physical memory in an HP-UX v11 OS when following are NOT available: - root account - no privileges in /proc - no privileges in /dev/mem Show Sample Output
Add up the amount of memory your processes are using and display the total. Replace marcanuy with your desired username. Show Sample Output
This command is better for just displaying the memory in KiB. Show Sample Output
The sample output is from an Android Device Show Sample Output
Clear Cached Memory on Ubuntu based distributions, and also display memory status. Please do not use this on a production machine unless you really really know what you are doing. Echo 3 is a kinder way of purging the memory, you can also use 'echo 2' or 'echo 1' if #1 You know what you are doing, and #2 refer to number 1 :-)
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: