Android execute script at logout I would like to execute a script at logout with my GS7 android 9 (Resurrection Remix). I see that it is advised to use tasker. I guess it is possible to do that without installing a graphical application.
I connect to the smartphone through adb and have a shell. Where can I write a file in the file system with bash or python commands that will be executed at logout ? Also, how should I manage the bash or python environment in order to have it working ?
Thanks for your time.
On a rooted device you can make use of init's on shutdown trigger:
# /etc/init/custom.rc

on shutdown
    exec - -- /path/to/executable

For more details on how to run an executable from init's .rc file, and what factors need to be taken care of, see my answer to How to run an executable on boot and keep it running?