[T-Mobile, Samsung Galaxy SIII] TomTcom:
Tasker is a great automation tool for Android. There are many ways to do tasks and automation so this is simply my way. Feel free to modify for yourself in any way and comment.

I'm using a T-Mobile Galaxy S3 running Anthem AOKP ROM with Android 4.2.2.

DISCLAIMER: If you don't know what fstrim is or does please do not use this guide until you understand fully.

DO NOT USE THIS WITH ANDROID 4.3. Why? Android 4.3 already includes an automated fstrim so you would be redundantly running this.

Assumptions in this guide:

1. You have ROOT.

2. You have Tasker app from the Play Store.

3. You have Secure Settings app from the Play Store.

4. You have Hacker's Keyboard app from the Play Store. Why?? I have not found a way to simulate a "long press" to create the ability to "paste". As a result, I use this keyboard and the 5 row compact layout that allows Tasker to physically touch the Ctrl key and the V key for pasting.

5. You are using the keyguard only, no PIN or Pattern. Tasker and Secure Settings allow this but you must select other options than Keyguard to make it work.

5a. The above is striked out because I was not having the correct success unlocking the "swipe" to unlock. As a result, this guide so far has only worked with no keyguard at all but I'm sure it will work fine if you substitute PIN and Pattern using Secure Settings.

6. You have fstrim utility.

To check if you have fstrim, open a terminal app and type "busybox". Look for fstrim in the results. If you have it proceed, if not you will need a custom busybox or a ROM that has the utility built into it.​

The next set of steps will create the required task and then the profile to run the task. In the end, we will run fstrim on 3 partitions and email the output of the results to ourselves. I do this for a "Daily Dashboard" of sorts. You don't need to do the email portion if you don't want. You can always just run the task or create it as an app using Tasker functionality.

1. Open your file manager and create a new file on the sdcard or the extsdcard. I will call my file in this guide "maintenance.log" and I will use the location of "/extSdCard/maintenance.log". You may choose whatever path and filename you wish.

2. Tap on the TASKS tab at the top of the app.

3. Tap the + and name it. I named mine Fstrim.

4. Tap Fstrim task and click the +. Select Plugin > Secure Settings > tap Edit > Wake Device > Screen & Keyboard Lights On. Choose a value. 4 seconds is fine because once the screen is on, it defaults to the normal Android timeout value of the lockscreen before it goes black. (freely change as needed)

5. Tap + and choose Plugin > Secure Settings > Keyguard > Off

5a. See the above 5a. strikeout reason. Here is where you could substitute PIN and Pattern.

6. Tap + and choose Script > Run Shell.

In the Command box, type rm /extSdCard/maintenance.log (this is used to delete the log on each run so we only have the output of the last fstrim run. Use whatever directory you wish to store the log file in and whatever filename you wish to use.​

7. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).

8. Tap + and choose Script > Run Shell > put these 4 commands in the Command field and tick the "Use Root" check box.

date >> /extSdCard/maintenance.log

fstrim -v /data >> /extSdCard/maintenance.log

fstrim -v /system >> /extSdCard/maintenance.log

fstrim -v /cache >> /extSdCard/maintenance.log​

9. Tap + and choose Display > System Lock

10. Tap on the TASKS tab at the top of the app.

11. Tap the + and name it. I named mine Maintenance Email.

12. Tap Maintenance Email task and click the +. Select Plugin > Secure Settings > tap Edit > Wake Device > Screen & Keyboard Lights On. Choose a value. 4 seconds is fine because once the screen is on, it defaults to the normal Android timeout value of the lockscreen before it goes black.

13. Tap + and choose Plugin > Secure Settings > Keyguard > Off.

13a. Again, here you can choose PIN and Pattern instead of keyguard.

14. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).

15. Tap + and choose File > Read File > put the location and filename in the field. > In "To Var" type %filecontents. (You can choose any variable name you wish).

16. Tap + and choose Misc > Set Clipboard > in the "Text field type %filecontents.

17. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).

18. Tap + and choose Net > Compose Email > put the recipient (yourself) and fill out Subject line.

19. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).

20. Tap + and choose Script > Run Shell > put these 3 commands in the Command field and tick the "Use Root" check box.

input tap 90 1232

input tap 320 1123

input tap 664 100​

21. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).

22. Tap on the PROFILES tab at the top of the app.

23. Tap + and choose Time. You only need to set whatever time you want in both "From" and "To" in order to have the task run every 24 hours. You shouldn't need to set the time with minutes in between. For example, I run mine at 4:30 every morning so both "From" and "To" are set to 4:30. Change this accordingly if you feel you need to.

24. Make sure your PROFILE is set to On.

25. Make sure Tasker is running, long press the gear icon at the top left when the app is open. You will see a toast notification that says enabled and when you exit the app, the running icon will be at the top left in your status bar.

26. Enjoy!