Page 1 of 1

[solved] Cron Trim on SSD

Posted: Tue Sep 18, 2018 12:50 pm
by HaveaMint
Since Ubuntu 14 Trim is done automatic through Cron, My question is that I have read to Trim manually on a multi partitioned ssd's

Code: Select all

sudo fstrim -v /
and

Code: Select all

sudo fstrim -v /home
had to be done for each partition; Does the cron job do all of the partitions on ssd's?

Re: Cron Trim on SSD

Posted: Tue Sep 18, 2018 12:59 pm
by AZgl1500
apparently it does, I am using a multi-partitioned SSD and here is a log of what it is doing.


0 18 * * * date >> /home/john/fstrim.log

5 18 * * * sudo fstrim -a -v >> /home/john/fstrim.log

==================================

Sun Sep 16 18:02:01 CDT 2018
/home/john/Backup: 134.9 GiB (144794890240 bytes) trimmed
/home: 71.5 GiB (76811853824 bytes) trimmed
/: 17.2 GiB (18487816192 bytes) trimmed
==================================

Mon Sep 17 18:02:01 CDT 2018
/home/john/Backup: 134.8 GiB (144771362816 bytes) trimmed
/home: 71.4 GiB (76671188992 bytes) trimmed
/: 17.1 GiB (18322153472 bytes) trimmed
==========================================

Re: Cron Trim on SSD

Posted: Tue Sep 18, 2018 1:00 pm
by Pippin
How does the cronjob look like?

On 18.3 I do a cron:

Code: Select all

fstrim -a
weekly, it will do all.

Manually with verbose:

Code: Select all

fstrim -av
/media/pippin/Data: 117,2 GiB (125828542464 bytes) trimmed
/home: 40 GiB (42987147264 bytes) trimmed
/: 9,5 GiB (10230333440 bytes) trimmed

Re: Cron Trim on SSD

Posted: Tue Sep 18, 2018 1:02 pm
by HaveaMint
Pippin wrote:
Tue Sep 18, 2018 1:00 pm
How does the cronjob look like?

On 18.3 I do a cron:

Code: Select all

fstrim -a
weekly, it will do all.

Manually with verbose:

Code: Select all

fstrim -av
/media/pippin/Data: 117,2 GiB (125828542464 bytes) trimmed
/home: 40 GiB (42987147264 bytes) trimmed
/: 9,5 GiB (10230333440 bytes) trimmed

Code: Select all

#!/bin/sh
# trim all mounted file systems which support it
/sbin/fstrim --all || true

Re: Cron Trim on SSD

Posted: Tue Sep 18, 2018 1:15 pm
by HaveaMint
I assume it does then, thanks for the replies.

Re: [solved] Cron Trim on SSD

Posted: Tue Sep 18, 2018 1:37 pm
by AZgl1500
I am using 18.3 Cinnamon,

and I built the crontab file this way

in Terminal $ sudo crontab -e



# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command

# you need the path statement so the logs go where they should

PATH="/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/local/sbin"

0 12 * * * cat /home/john/add-line >> /home/john/mintupdatetoolcron.log

1 12 * * * date >> /home/john/mintupdatetoolcron.log

2 12 * * * mintupdate-tool -r -l 123 -y -s -nk upgrade >> /home/john/mintupdatetoolcron.log

# comment, the above is my Linux Upgrades job, below is the fstrim job

0 18 * * * cat /home/john/add-line >> /home/john/fstrim.log

2 18 * * * date >> /home/john/fstrim.log

5 18 * * * sudo fstrim -a -v >> /home/john/fstrim.log

Re: [solved] Cron Trim on SSD

Posted: Wed Sep 19, 2018 2:04 am
by smurphos
There is a default systemd based weekly job for this in both Mint 18.3 and Mint 19. No need for extra cronjobs.

See output of
systemctl cat fstrim.timer
systemctl cat fstrim.service

To confirm it's working on your SSD run

journalctl | grep fstrim

Re: [solved] Cron Trim on SSD

Posted: Wed Sep 19, 2018 2:38 am
by HaveaMint
smurphos wrote:
Wed Sep 19, 2018 2:04 am
.
DOH! I was fixing to run the commands to check it out and realized i'm on the laptop now, I will check it out when I get home though. Thanks Smurf

Re: [solved] Cron Trim on SSD

Posted: Wed Sep 19, 2018 9:59 am
by AZgl1500
smurphos wrote:
Wed Sep 19, 2018 2:04 am
There is a default systemd based weekly job for this in both Mint 18.3 and Mint 19. No need for extra cronjobs.

See output of
systemctl cat fstrim.timer
systemctl cat fstrim.service

To confirm it's working on your SSD run

journalctl | grep fstrim
The post I made above was with your help a few months back, and it is working perfectly for me.

The commands you listed above, don't output anything on this laptop.

Code: Select all

john@john-TP500LA ~ $  systemctl cat fstrim.timer
No files found for fstrim.timer.
john@john-TP500LA ~ $  systemctl cat fstrim.service
No files found for fstrim.service.
john@john-TP500LA ~ $ 

Re: [solved] Cron Trim on SSD

Posted: Wed Sep 19, 2018 11:48 am
by HaveaMint

Code: Select all

 $ systemctl cat fstrim.timer
No files found for fstrim.timer.
$ systemctl cat fstrim.service
No files found for fstrim.service.
No luck running these on mine either
My default on 18.3 XFCE is a cron job weekly.

Code: Select all

#!/bin/sh
# trim all mounted file systems which support it
/sbin/fstrim --all || true

Re: [solved] Cron Trim on SSD

Posted: Wed Sep 19, 2018 12:54 pm
by smurphos
AZgl1500 wrote:
Wed Sep 19, 2018 9:59 am
The commands you listed above, don't output anything on this laptop.
HaveaMint wrote:
Wed Sep 19, 2018 11:48 am
No luck running these on mine either
My mistake - looks like the fstrim services are only on 19. Anyway - here's the output from a Mint 19 machine - I only fitted the SSD a couple of weeks ago and reinstalled.

Code: Select all

$ systemctl cat fstrim.service
# /lib/systemd/system/fstrim.service
[Unit]
Description=Discard unused blocks

[Service]
Type=oneshot
ExecStart=/sbin/fstrim -av

Code: Select all

$ systemctl cat fstrim.timer
# /lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim

[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target

Code: Select all

$ journalctl | grep fstrim
Sep 03 05:16:15 steve-HP-Pavilion-g6-Notebook-PC fstrim[992]: /home: 83.8 GiB (89968123904 bytes) trimmed
Sep 03 05:16:15 steve-HP-Pavilion-g6-Notebook-PC fstrim[992]: /: 24.1 GiB (25918345216 bytes) trimmed
Sep 11 05:36:16 steve-HP-Pavilion-g6-Notebook-PC fstrim[988]: /home: 83.8 GiB (89917333504 bytes) trimmed
Sep 11 05:36:16 steve-HP-Pavilion-g6-Notebook-PC fstrim[988]: /: 24 GiB (25781080064 bytes) trimmed
Sep 17 05:09:18 steve-HP-Pavilion-g6-Notebook-PC fstrim[984]: /home: 83.2 GiB (89315753984 bytes) trimmed
Sep 17 05:09:18 steve-HP-Pavilion-g6-Notebook-PC fstrim[984]: /: 23.5 GiB (25242152960 bytes) trimmed

Re: [solved] Cron Trim on SSD

Posted: Wed Sep 19, 2018 1:27 pm
by HaveaMint
smurphos wrote:
Wed Sep 19, 2018 12:54 pm
.
My mistake - looks like the fstrim services are only on 19. Anyway - here's the output from a Mint 19 machine - I only fitted the SSD a couple of weeks ago and reinstalled.

Code: Select all

$ journalctl | grep fstrim
Sep 03 05:16:15 steve-HP-Pavilion-g6-Notebook-PC fstrim[992]: /home: 83.8 GiB (89968123904 bytes) trimmed
Sep 03 05:16:15 steve-HP-Pavilion-g6-Notebook-PC fstrim[992]: /: 24.1 GiB (25918345216 bytes) trimmed
Sep 11 05:36:16 steve-HP-Pavilion-g6-Notebook-PC fstrim[988]: /home: 83.8 GiB (89917333504 bytes) trimmed
Sep 11 05:36:16 steve-HP-Pavilion-g6-Notebook-PC fstrim[988]: /: 24 GiB (25781080064 bytes) trimmed
Sep 17 05:09:18 steve-HP-Pavilion-g6-Notebook-PC fstrim[984]: /home: 83.2 GiB (89315753984 bytes) trimmed
Sep 17 05:09:18 steve-HP-Pavilion-g6-Notebook-PC fstrim[984]: /: 23.5 GiB (25242152960 bytes) trimmed
No problem, I appreciate the input. My weren't you the busy little penguin shuffling things around . :D