Linux/Snippets: Difference between revisions

From Wiki
No edit summary
No edit summary
Line 4: Line 4:
<pre>
<pre>
clear;  for each in $(ls) ; do du -hs "$each" ; done
clear;  for each in $(ls) ; do du -hs "$each" ; done
</pre>
</blockquote>
Measure execution time
<blockquote>
<pre>
START=$(date +%s.%N)
command
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
</pre>
</pre>
</blockquote>
</blockquote>

Revision as of 11:16, 18 November 2012

File system & drives

List directory sizes

clear;   for each in $(ls) ; do du -hs "$each" ; done


Measure execution time

START=$(date +%s.%N)
command
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)


show hdd power states

sudo hdparm -C /dev/sd?


Manual SSD Trim

sudo fstrim -v /   


Cron SSD Trim

/etc/scripts/fstrim.sh:
#!/bin/sh
#
echo `date +"%d %b %H:%M:%S"` | tr -d '\n' >> /var/log/fstrim
/sbin/fstrim -v / >> /var/log/fstrim
/etc/cron.d/fstrim:
#
0 * * * * root /etc/scripts/fstrim.sh