7

I need to run a script that sets cpu_freq .In order to retain the settings after reboot i need to run script which takes care of this issue.I tried to write service in init.rc but the edited part in init.rc disappears on reboot .is there some other way to start script on reboot.thanks

1

5 Answers 5

6

I've found success with magisk. When installed, it adds a directory for boot scripts under /data/adb/service.d, in which you can throw your shell scripts and have them executed by Magisk on boot.

For example, I have the following script:

#!/bin/sh sleep 15 # to make sure we aren't running in an early stage of the boot process crond -b -c /data/crontab/ 

Once created as /data/adb/service.d/start-crond.sh and made executable, it automatically launches crond at boot (provided by Magisk's internal busybox instance).

Sign up to request clarification or add additional context in comments.

1 Comment

It worked! Had to put sleep 30 instead of 15 in my case. Thank you.
1

Use Script Manager.

2 Comments

I wrote an init script which changes the governor and maintains the settings.runs on every reboot
A link to a potential solution is always welcome, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. Take into account that being barely more than a link to an external site is a possible reason as to Why and how are some answers deleted?.
0

This link may be helpful:

[ADDON][Xperia S] Generic startup/init.d scripts support for Stock ROM/Kernel http://forum.xda-developers.com/showthread.php?t=1547238

Although it is for Xperia S, it also works for my ideos. I think the theory behind is quite generic. And if you have installed busybox, you can unzip the downloaded package, read the batch and make some change to the phone by yourself.

If you really want to run your script manually after boot, I prefer scriptme in play market. It's simple and small.

1 Comment

The linked add-on is no longer available. Can you edit your answer to include the relevant information about what changes it makes to the system to make this work?
0
#!/system/bin/sh echo "It runs" > /some_path/some_file.txt 

chmod +- /data/adb/service.d/file.sh

1 Comment

It'd help if you breakdown on what the command is actually doing.
-1

I had tried to put a script with a simple echo "It runs" > /some_path/some_file.txt command.

It is redirected to a read/write (-rw--rw--rw-) file onto a read/write (drwxrwxrwx) folder.

I also had tested with the script having (-rwx-rwx-rwx) as well as (-rwx-rwx-r-x), etc., no luck at all.

I tested with and without having the file /some_path/some_file.txt, i test with /some_path be every where i could try (also sd-card folders, also internal memory, also where script is and also not putting full path at all).

The file is not modified if exists and is not created if it does not exist, so i can assume the script is not run.

What user/group must have the script? i had tested also with root/root but no luck.

The code:

#!/bin/sh echo "It runs" > /some_path/some_file.txt 

I had test saving it as test.sh, no matter if i put it onto /data/adb/service.d/ and/or onto /data/adb/post-fs-data.d/ folder/s, it get never run.

I had done more than two hundred tests, no luck at all... looks like Magisk is not running the script.

1 Comment

This more looks like a question and added to comment to the answer detailing magisk

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.