[solved] Cron Trim on SSD

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
HaveaMint
Level 6
Level 6
Posts: 1085
Joined: Fri Feb 02, 2018 9:56 pm

[solved] Cron Trim on SSD

Post 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?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
"Tune for maximum Smoke and then read the Instructions".
User avatar
AZgl1800
Level 20
Level 20
Posts: 11171
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 AZgl1800 »

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 AZgl1800 on Tue Sep 18, 2018 1:29 pm, edited 1 time in total.
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
User avatar
Pippin
Level 4
Level 4
Posts: 441
Joined: Wed Dec 13, 2017 11:14 am
Location: The Shire

Re: Cron Trim on SSD

Post 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
I gloomily came to the ironic conclusion that if you take a highly intelligent person and give them the best possible, elite education, then you will most likely wind up with an academic who is completely impervious to reality.
Halton Arp
HaveaMint
Level 6
Level 6
Posts: 1085
Joined: Fri Feb 02, 2018 9:56 pm

Re: Cron Trim on SSD

Post 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
"Tune for maximum Smoke and then read the Instructions".
HaveaMint
Level 6
Level 6
Posts: 1085
Joined: Fri Feb 02, 2018 9:56 pm

Re: Cron Trim on SSD

Post by HaveaMint »

I assume it does then, thanks for the replies.
"Tune for maximum Smoke and then read the Instructions".
User avatar
AZgl1800
Level 20
Level 20
Posts: 11171
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 AZgl1800 »

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
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: [solved] Cron Trim on SSD

Post 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
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
HaveaMint
Level 6
Level 6
Posts: 1085
Joined: Fri Feb 02, 2018 9:56 pm

Re: [solved] Cron Trim on SSD

Post 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
"Tune for maximum Smoke and then read the Instructions".
User avatar
AZgl1800
Level 20
Level 20
Posts: 11171
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 AZgl1800 »

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 ~ $ 
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
HaveaMint
Level 6
Level 6
Posts: 1085
Joined: Fri Feb 02, 2018 9:56 pm

Re: [solved] Cron Trim on SSD

Post 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
"Tune for maximum Smoke and then read the Instructions".
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: [solved] Cron Trim on SSD

Post 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
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
HaveaMint
Level 6
Level 6
Posts: 1085
Joined: Fri Feb 02, 2018 9:56 pm

Re: [solved] Cron Trim on SSD

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

Return to “Hardware Support”