简体   繁体   English

在设备启动时从init.rc运行脚本的问题

[英]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: 我正在尝试运行一个shell脚本,它将文件复制到一个特定的位置,在手机上电,我将以下内容添加到我的init.rc文件中:

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. 当服务名称(test_copy)是相同的脚本名称, test_copy在这种情况下,不执行脚本,但如果我改变服务名称为不同的一种,像start_test_copy ,它的工作原理。 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: 在init.rc中尝试这个:

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

Your test_copy.sh script must begin with: 您的test_copy.sh脚本必须以:

#!/system/bin/sh

Always make sure use a different name for your service which Android init recommends. 始终确保为Android init推荐的服务使用其他名称。

Also, you can make your test_copy.sh into the executable by defining the Android Make file. 此外,您可以通过定义Android Make文件将test_copy.sh变为可执行文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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