Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs
16 votes
Accepted

How to run an executable on boot and keep it running?

How much is the possibility that Android will kill my executable? Privileged native processes usually don't get killed by Android except if they can't handle an error occurred inside, such as some ...
Irfan Latif's user avatar
  • 20.6k
8 votes

How can I run a script on boot?

If you have Magisk installed you can place the .sh to: /sbin/.magisk/img/.core/service.d/ or to /sbin/.magisk/img/.core/post-fs-data.d/ Don't forget to make it executable: chmod +x your-script.sh. ...
H. Hess's user avatar
  • 181
8 votes
Accepted

Where can I run a .sh script on Android without root?

/storage/emulated/0 is usually mounted in a way that prevents execution of programs from this location. Therefore even with a set executable bit for your script you won't be able to execute it ...
Robert's user avatar
  • 20.3k
6 votes
Accepted

How to run an Android init service with superuser SELinux context?

Here the error is: audit: type=1400 audit(1560142274.289:131): avc: denied { transition } for pid=8035 comm="init" path="/system/bin/custom.sh" dev="sda24" ino=8146 scontext=u:r:init:s0 tcontext=u:r:...
Irfan Latif's user avatar
  • 20.6k
5 votes
Accepted

Android stops/pauses execution of my background script?

Android turns off some of CPUs and/or don't let apps use them when it's dozing. It's achieved through Linux kernel's Control Groups. One of the cgroups is cpuset that controls which CPU is assigned to ...
Irfan Latif's user avatar
  • 20.6k
4 votes
Accepted

How to detect GPS status through adb shell?

You can use this command: adb shell settings get secure location_providers_allowed Possible outcomes: returns nothing, implying the GPS is switched off. gps,wifi,network or gps,network -- High ...
Firelord's user avatar
  • 25.1k
4 votes
Accepted

Show a piece of a Google Spreadsheet document on Andriod main screen

Many thanks to beeshyams. Here is a way to do what I wanted. This app allows to parse chosen content from any web page and use it as a widget. In order to have a Spreadsheets document as a web page ...
Helyrk's user avatar
  • 81
4 votes

How can I run a script on boot?

I tried all these methods and none of them worked for me. What worked however was based on lord-ralf-adolf's answer here How to run a script on boot in CM12.1? basically, find the file /system/etc/...
Ramast's user avatar
  • 206
4 votes
Accepted

How to run a script in background from adb shell?

Processes receive signals from other processes or kernel as a warning or as a request to make some change in state. Receiving processes can block, ignore or catch signals, except SIGKILL which does ...
Irfan Latif's user avatar
  • 20.6k
3 votes

How would I automate repetitive tasks in Android?

A great app for that is Automate. I've used it with great success. There are a few plugins that exist; you may or may not need them The main app is here Based on your use case, you may want this, ...
unixandria's user avatar
3 votes
Accepted

How to enable "Disable HW overlays" at startup?

Source-reddit, which references Android documentation to DISABLE the h/w composer: adb shell service call SurfaceFlinger 1008 i32 1 to ENABLE the h/w composer: adb shell service call SurfaceFlinger ...
beeshyams's user avatar
  • 41k
2 votes

how can I randomize my MAC address every time my WiFi is turned on?

In addition to the other answer with Tasker ("You could do that using e.g. Tasker, the mighty automation tool:"), here a little Task (description export) with randomizing the MAC: TestMacChanger (130)...
franc's user avatar
  • 417
2 votes
Accepted

Reason for chroot failure: tmp-mksh: chroot: not found

The Reason for this failure is that Android blocked chroot for som reason. Like Death Mask Salesman pointed out, it is possible to get information about the command type via type commandName e.g. in ...
goulashsoup's user avatar
2 votes

How can I run a shell script when some WiFi is connected?

Matthew already pointed to tasker for this task (uh) – an app I already use for years. So let me add the steps to achieve this. Obviously, a pre-condition is the device is rooted – but the su command ...
Izzy's user avatar
  • 91.1k
2 votes

How can I run a custom .sh script at each startup (without native init.d support)?

I think that most easy way would be by using app Kernel Adiutor. It has ability to emulate init.d Open app and swipe from left edge, it will reveal menu, scroll to tools section and than tap on init.d ...
Једноруки Крстивоје's user avatar
2 votes

Staging of several android devices made simple

I've just stumbled upon a project at Github, and remembered your question here. It seems like inception should perfectly fit your needs (except for the Google account, maybe, where it's a bad idea ...
Izzy's user avatar
  • 91.1k
2 votes
Accepted

Script to pull from directory containing spaces

Get doublequotes: for file in $(./adb shell ls \""$DEVICE_DIR"\") ^ ^ ./adb pull "$DEVICE_DIR/$file" $HOST_DIR/; ^ ^ And remove ...
iBug's user avatar
  • 7,767
2 votes

How would I automate repetitive tasks in Android?

The best one I've ever come across is Tasker. It isn't necessarily coding but you do get to script your tasks in a scratch fashion. Although I don't see how it might be different from Automate which ...
Abhyas29's user avatar
2 votes

execute ussd from shell-script

replace # to %23, so: service call phone 2 s16 '*100%23' or am start -a android.intent.action.CALL -d tel:*100%23
Vitaly Zdanevich's user avatar
2 votes
Accepted

How to automate sending my current battery percentage to PC over the internet every 5 minutes?

I'm using gist by Github (which can be done using gem install gist after installing ruby package) for broadcasting my battery percentage first to a private file, tried using ix.io but pkg install ix ...
himanshuxd's user avatar
2 votes

How can I Automate for selected apps to only use cellular data and not Wi-Fi... and vise versa?

On the Apps section, select App in foreground? Tap on the block. On the package option, select your app. Press Save. On the Connectivity section, select Wi-Fi set state block. Set the Wi-Fi option to ...
Reddy Lutonadio's user avatar
2 votes

How can I install Greasemonkey, Tampermonkey, or similar in Firefox Android?

On Firefox you need to enable the debug menu by going to settings -> about Firefox then pressing the Firefox logo at least 5 times. The same applies to Mull and other forks. Once you had done that, ...
PatoPan's user avatar
  • 23
1 vote
Accepted

how to display text on TWRP recovery screen using a sh file?

This piece of code is extracted from the ZIP package of SuperSU. It's working correctly on all devices I've ever had (displaying text to the TWRP terminal) OUTFD=1 readlink /proc/$$/fd/$OUTFD 2>/...
iBug's user avatar
  • 7,767
1 vote

Commands run on terminal but throw errors in shell script

Apparently there seems no reason for this, except the possible problem with line endings which often happens. On *NIX operating systems (including Android), lines end with Line Feed (LF; \n or 0x0A) ...
Irfan Latif's user avatar
  • 20.6k
1 vote
Accepted

How to Check if Script is run once device is booted?

mkshrc is by definition run every time an interactive shell is started, so it’s the wrong place. You really should hook up your script with Android’s init system instead. (Sorry, I can’t give details ...
mirabilos's user avatar
  • 663
1 vote
Accepted

How can I run a custom .sh script at each startup (without native init.d support)?

Simple way (working): Prepare your post boot commands in a script, say /system/xbin/post-boot (set exec perm) Add the above custom script path at the end of /system/etc/init.qcom.post_boot.sh Eg: # ...
Seff's user avatar
  • 136
1 vote

How can I run a custom .sh script at each startup (without native init.d support)?

From my answer on another question, I have two methods here. 1. Add init.d support manually by editing init.rc I haven't done this ever personally but I can tell that You need to unpack and repack ...
iBug's user avatar
  • 7,767
1 vote
Accepted

TWRP recovery: "pm install /path/to.apk" not working

Use script to place the APK file at the correct place in /data/app instead. mkdir,mv,chown and chmod are to be used. While pm binary is there, it cannot do it's work from recovery that is a ...
Zulgrib's user avatar
  • 431
1 vote

Termux/node.js steam hourboost on android

From the console it seems, the script requires root privileges to be executed which are not available/disabled on your device
xavier_fakerat's user avatar
1 vote
Accepted

Tasker to run scripts in terminal shell

This can be easily achieved by using Tasker. Instructions: Create a named task. A1: Code >> Run Shell [Command: (insert any code you wish to run) Store Output: (insert any variable which will ...
xavier_fakerat's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible