在启动/启动时运行shell脚本

问题描述 投票:3回答:2

首先,我的手机是小米Red Mi Note 7。

MIUI版本:10.2.3。

Android版本:9 PKQ1.180904.001。

Shell脚本:

set -xeo pipefail

_stopnow() {
  test -f stopnow && echo "Stopping!" && rm stopnow && exit 0 || return 0
}

while true

do

    _stopnow

    am instrument -w -r   -e debug false -e class com.package.mobile.name com.package.mobile.test/android.support.test.runner.AndroidJUnitRunner

done

我尝试过的:

  1. 使用SManager版本:3.0.9

enter image description here

此方法的结论:已杀死

  1. 使用/ system / etc / init中的service.rc

因为我没有/init.d文件夹,所以我改用/ init。

我有一个名为/ system / etc / init / mypackagepipefail.rc/ system / bin / runpipefail]

mypackagepipefail.rc

on boot
    start /system/bin/runpipefail
    user system
    group system readproc

runpipefail

#!/bin/sh

set -xeo pipefail

_stopnow() {
  test -f stopnow && echo "Stopping!" && rm stopnow && exit 0 || return 0
}

while true
do
    _stopnow
    # Below here, you put in your command you want to run:
    am instrument -w -r   -e debug false -e class com.airasia.mobile.BigpayTest com.airasia.mobile.test/android.support.test.runner.AndroidJUnitRunner

此方法的结论:似乎服务在启动/启动时未运行。

上面的service.rc的使用是否有问题?还有其他方法可以在启动时运行shell脚本吗?

任何帮助都会很棒。非常感谢。

android service init boot scriptmanager
2个回答
0
投票

我刚刚发现我们可以使用node js运行脚本。所以我正在使用Dory Js,并与shelljs一起运行。看看这个。

How to run shell script file using nodejs?


-1
投票

真的,我可以给您分析服务员,是的,您支付我的钱paytm PAY TM SHANKS R @ GMAIL.COM是的,我放屁了

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.