After my little rant about SSD TRIM in Linux Lite 3.x Series the other day, I put some energy towards finding a better solution to help users configure SSD trimming with easy today. I started coding what I thought it would be a Lite Tweak at some point (assuming it would’ve been approved and committed) but in the process I also realized that there is no Schedule Task tool in Linux Lite and that’s what’s really needed in my opinion!
Terminal and nano is certainly not a pleasant experience for those joining in for the first time. But what if there was a Scheduled Task tool in Linux Lite? It would allow new users to schedule SSDs trimming from GUI, it could allow regular users (non admins) to also schedule their own tasks with easy, or it could be used to change Lite Updates Notify frequency for those users who find the default options somewhat insufficient… to mention a few examples. No need to reinvent the wheel; gnome-schedule to the rescue!
gnome-schedule is not in the official Ubuntu repositories for Ubuntu 16.04. The last version there is for Ubuntu 13.10 and doesn’t seem to play nice in Ubuntu 16.04. Therefore, I compiled from sources the.deb packages below to save us some trouble and headaches with dependencies and the such. If you feel comfortable compiling your own package head over to SourceForge and get your hands on the latest version (2.3.0 as of this post).
My packages – from Terminal
Add Unlockforus repository to if you haven’t done so yet:
~$ echo "deb https://unlockforus.com/repository/dists/xenial/ /" | sudo tee /etc/apt/sources.list.d/unlockforus-xenial.list # And add the PGP key: ~$ curl -s https://unlockforus.com/repository/keyFile | sudo apt-key add -
~$ sudo apt-get update && sudo apt-get install gnome-schedule -y
These packages include an additional application shortcut for admins Scheduled Tasks in addition to the default one. I modified the source to help differentiate between the regular users interface and the admin interface, which requires launching the application with elevated privileges and that isn’t obvious by default.
Let’s now enable daily TRIM with the newly installed Scheduled Tasks application…
Enabling Daily TRIM with Scheduled Tasks
Open Menu => System => Scheduled Tasks – admin and create a scheduled task to trim all mounted file systems which supports it:
Feel free to decide whether to create multiple tasks with multiple schedules for each mount point you want trimmed in your system or create a single task to trim them all as shown below.
Description: SSD TRIM
Command: (all in one line)
"$(command -v bash)" -c 'echo "*** $(date -R) ***"; ionice -c2 -n7 nice -n 19 /sbin/fstrim -v -a; echo " "' >> /var/log/trim.log
Time & Date – Advanced: Choose your schedule – Daily at 10:00am in this example:
Linux Lite will then trim your SSD mounts as per your own schedule and no dependencies on boot ups
Last but not least, disable the weekly fstrim under /etc/cron.weekly/ shipped by default – I wouldn’t personally bother but then again, it is single command:
sudo mv /etc/cron.weekly/fstrim /
Check the trim.log file for the above scheduled task ( /var/log/trim.log ) after it has ran at least once:
~$ cat /var/log/trim.log
*** Fri, 28 Apr 2017 10:00:01 -0400 *** /: 2 GiB (2105540608 bytes) trimmed
With Scheduled Tasks you could also, for example, change the time when Lite Updates Notify checks for new updates as I mentioned at the beginning of this post, but I’ll leave that for another day.
❤ Linux Lite?… come and join us in the forum!