Skip to content

Instantly share code, notes, and snippets.

Created September 19, 2014 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b93d9c73ea149f0fc35f to your computer and use it in GitHub Desktop.
Save anonymous/b93d9c73ea149f0fc35f to your computer and use it in GitHub Desktop.
Cron job to run fstrim
#!/bin/sh
# Script to do SSD trim operations
# Based on: http://askubuntu.com/questions/18903/how-to-enable-trim
if [ "$(cat /sys/class/power_supply/AC/online)" = "0" ]
then
# running off the battery: abort
exit 0
fi
# all mount points of SSD drives:
SSD_MOUNT_POINTS='/ /boot /home'
for mount_point in $SSD_MOUNT_POINTS
do
fstrim $mount_point
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment