RanjitRock
RanjitRock

Reputation: 1441

how to run script at boot-time?

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

Upvotes: 7

Views: 19162

Answers (5)

Big load
Big load

Reputation: 1

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

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

Upvotes: 0

Laura
Laura

Reputation: 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.

Upvotes: -1

Maor
Maor

Reputation: 73

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).

Upvotes: 5

kidault
kidault

Reputation: 16

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.

Upvotes: 0

Gaurav
Gaurav

Reputation: 1516

Use Script Manager.

Upvotes: 1

Related Questions