For custom scripts at boot, we have init.d. I want to know if there's a possibility of executing a custom script when shutting down, something similar to init.d or by using an APK?

  • 1
    You could make an app that receives the SHUTDOWN intent. Commented Mar 9, 2016 at 6:05
  • I think you can create a xposed framework module for that purpose. Commented Mar 9, 2016 at 7:05

2 Answers 2


Our default answer on questions like this is – whenever it comes to , this is the most powerful tool to be mentioned. Tasker combines Contexts (Events, states, location, time) with Tasks to be fired when such a context is met. For your case, there's an event called Device Shutdown – which you could combine with the task Code › Run Shell to execute your shutdown scripts.

For further reading, I strongly recommend you visiting our tasker tag-wiki, which also links to additional resources like the tasker user-guide or my collection of tasker resources.


This is not easy. especially for scripts that have to run after zygote was stopped. Try to digg /*.rc scripts. may be attaching to the swapoff action help you. There are some mod projects at xda too https://forum.xda-developers.com/showthread.php?t=1387692

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .