Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run script at boot-time?

Tags:

android

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

like image 601
RanjitRock Avatar asked Oct 24 '11 09:10

RanjitRock


People also ask

How do I add scripts to startup?

For Linux startup scripts, you can use bash or non-bash file. To use a non-bash file, designate the interpreter by adding a #! to the top of the file. For example, to use a Python 3 startup script, add #! /usr/bin/python3 to the top of the file.


1 Answers

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

like image 57
Maor Avatar answered Oct 11 '22 21:10

Maor