The util-linux package provides fstrim.service and fstrim.timer systemd unit files.
Enabling the timer will activate the service weekly. The service executes fstrim(8) on all mounted filesystems on devices that support the discard operation.
The timer relies on the timestamp of /var/lib/systemd/timers/stamp-fstrim.timer (which it will create upon first invocation) to know whether a week has elapsed since it last ran.
Therefore there is no need to worry about too frequent invocations, in an anacron-like fashion. systemctl enable fstrim.timer
To query the units activity and status, see journalctl.
To change the periodicity of the timer or the command run, edit the provided unit files.https://wiki.archlinux.org/title/Solid_state_drive