Hi folks, I wrote this script which works but it should run automatically about once per week.
I hunted and experimented with KDE Task Scheduler (no dice and no help anywhere) and cron (confusing instructions and cannot edit crontab -e with vim, and cannot enter cron folders/files).
I would settle for a desktop shortcut to run the script but found no help for that.
Script:
#!/bin/bash
xterm -hold -e fstrim -v /
OS: openSUSE 11.4 x86_64
Kernel: Linux 2.6.37.6-0.5-desktop
Desktop: KDE 4.6.00 rel 6
I am not asking anyone to write code, I could use some pointers, though.
As @Ecky tells you, puting it there will let it be run as root.
When this should not run as *root, *you should use the users crontab.
But I have doubts about this running in an *xterm. *Things run by cron are batch runs. Thus thre is no X screen connected to them. And as xterm is an X program, this will be a problem. Why not just run he program?
I wound up modifying the fstab so trim would occur on every cold boot and restart. It would be easier to view this thread I started in Linux Questions:SSD Trim simple bash script program But I backed up the drive image with Image for Linux and when attempting to restore, the last image I made showed 0 bytes and asked for the media even though it and all images are kept on a second drive. I have to do more testing to find out if the fstab mods caused this. Otherwise, it may be cron.
In fact, the question which partition needs trimming has not been definitively answered AFAIK.
You did not ask for any advise about the fstrim tool. You asked for advise about
it should run automatically about once per week.
and then you added some vague statements about strange things you tried using cron.
Thus an advise was given how to run a statement once a week as root (and that statement can of course be a call of a much larger script.
Thus I guess your question was answered.
When you want advise on the usage of fstrim (after reading the it’s man page), you better make a new thread with at least the word “fstrim” in the title to lure fstrim gurus into helping you.