简体   繁体   中英

Issue running a script from init.rc on device boot up

I am trying to run a shell script, which copies a file to a specific location, on phone power up and I added the following to my init.rc file:

service test_copy /system/bin/sh /system/bin/test_copy.sh  
    class pre-zygote_services  
    oneshot  
    user system  
    group system  

When the service name (test_copy) is same as the script name, test_copy in this case, it doesn't execute the script but if I change the service name to a different one, like start_test_copy , it works. I am just eager to know the reason on why when service name is same as script name it doesn't work or am I wrong?

Try this one in your init.rc:

service test_copy /system/bin/test_copy.sh
user root
oneshot

Your test_copy.sh script must begin with:

#!/system/bin/sh

Always make sure use a different name for your service which Android init recommends.

Also, you can make your test_copy.sh into the executable by defining the Android Make file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM