[solved] Cron Trim on SSD

Questions about hardware,drivers and peripherals
Forum rules
Before you post please read how to get help
Post Reply
HaveaMint
Level 4
Level 4
Posts: 426
Joined: Fri Feb 02, 2018 9:56 pm
Location: Somewhere in the USA
Contact:

[solved] Cron Trim on SSD

Post by HaveaMint » Tue Sep 18, 2018 12:50 pm

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?
Last edited by HaveaMint on Tue Sep 18, 2018 1:16 pm, edited 1 time in total.
"Tune for maximum Smoke and then read the Instructions".

User avatar
AZgl1500
Level 9
Level 9
Posts: 2719
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes sweeping down the plains
Contact:

Re: Cron Trim on SSD

Post by AZgl1500 » Tue Sep 18, 2018 12:59 pm

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
==========================================
Last edited by AZgl1500 on Tue Sep 18, 2018 1:29 pm, edited 1 time in total.

Pippin
Level 3
Level 3
Posts: 159
Joined: Wed Dec 13, 2017 11:14 am
Location: NL/DE/TH

Re: Cron Trim on SSD

Post by Pippin » 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
"I'm not in this world to live up your expectations, neither are you here to live up to mine.”
F.P. & P.T.

HaveaMint
Level 4
Level 4
Posts: 426
Joined: Fri Feb 02, 2018 9:56 pm
Location: Somewhere in the USA
Contact:

Re: Cron Trim on SSD

Post by HaveaMint » Tue Sep 18, 2018 1:02 pm

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
"Tune for maximum Smoke and then read the Instructions".

HaveaMint
Level 4
Level 4
Posts: 426
Joined: Fri Feb 02, 2018 9:56 pm
Location: Somewhere in the USA
Contact:

Re: Cron Trim on SSD

Post by HaveaMint » Tue Sep 18, 2018 1:15 pm

I assume it does then, thanks for the replies.
"Tune for maximum Smoke and then read the Instructions".

User avatar
AZgl1500
Level 9
Level 9
Posts: 2719
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes sweeping down the plains
Contact:

Re: [solved] Cron Trim on SSD

Post by AZgl1500 » Tue Sep 18, 2018 1:37 pm

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

User avatar
smurphos
Level 8
Level 8
Posts: 2007
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: [solved] Cron Trim on SSD

Post by smurphos » 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

HaveaMint
Level 4
Level 4
Posts: 426
Joined: Fri Feb 02, 2018 9:56 pm
Location: Somewhere in the USA
Contact:

Re: [solved] Cron Trim on SSD

Post by HaveaMint » Wed Sep 19, 2018 2:38 am

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
"Tune for maximum Smoke and then read the Instructions".

User avatar
AZgl1500
Level 9
Level 9
Posts: 2719
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes sweeping down the plains
Contact:

Re: [solved] Cron Trim on SSD

Post by AZgl1500 » Wed Sep 19, 2018 9:59 am

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 ~ $ 

HaveaMint
Level 4
Level 4
Posts: 426
Joined: Fri Feb 02, 2018 9:56 pm
Location: Somewhere in the USA
Contact:

Re: [solved] Cron Trim on SSD

Post by HaveaMint » Wed Sep 19, 2018 11:48 am

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
"Tune for maximum Smoke and then read the Instructions".

User avatar
smurphos
Level 8
Level 8
Posts: 2007
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: [solved] Cron Trim on SSD

Post by smurphos » Wed Sep 19, 2018 12:54 pm

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

HaveaMint
Level 4
Level 4
Posts: 426
Joined: Fri Feb 02, 2018 9:56 pm
Location: Somewhere in the USA
Contact:

Re: [solved] Cron Trim on SSD

Post by HaveaMint » Wed Sep 19, 2018 1:27 pm

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
"Tune for maximum Smoke and then read the Instructions".

Post Reply

Return to “Hardware Support”