An SSD stays fast when it knows which blocks no longer hold data. A weekly trim is enough for most machines.
sudo fstrim -av
systemctl status fstrim.timer
-a trims every mounted filesystem that supports it and -v prints how many bytes were passed down to the device. Ubuntu enables fstrim.timer by default, so check that before you add a cron job. A filesystem on a virtual disk or on some hardware RAID setups does not support trim, and with -a fstrim silently skips them, so no output for a mount can mean it was skipped.
Further reading: fstrim manual page