[英]Init.rc : service killed and restarts
I'm running shell script in init.rc as a service but it killed and restarts continuously. 我在作为服务的init.rc中运行shell脚本,但它被终止并不断重启。
Service registering in init.rc as follows 在init.rc中注册服务,如下所示
service Storelog /system/bin/logwrapper /system/bin/store_log.sh
user root
disabled
and script store_log.sh is 和脚本store_log.sh是
#!bin/sh
while true
do
echo "Updating system log.."
logcat > /data/system.log &
sleep 600
echo "Killing background logcat."
logpid=$!
echo "logpid $logpid"
kill $logpid
logcat -c
done
and I am starting this Storelog on some trigger like boot_completed 我在一些类似boot_completed的触发器上启动这个Storelog
This service starts, after one loop its killed and restarted. 终止一个循环并重新启动后,此服务将启动。
What I am missing here ?? 我在这里想念的是什么?? some permission ??
一些许可? Any suggestion are helpful.
任何建议都是有帮助的。
according to this page: http://developer.android.com/tools/help/logcat.html 根据此页面: http : //developer.android.com/tools/help/logcat.html
the '-c' option causes logcat to exit -c选项导致logcat退出
however, by then, the 'kill' has already exited logcat. 但是,到那时,“ kill”已经退出logcat。
suggest modifying the script to: (following untested) 建议将脚本修改为:(以下未经测试)
#!bin/sh
while true
do
echo "Updating system log.."
logcat -d > /data/system.log &
sleep 600
done
you can try to add oneshot tag to the service 您可以尝试将oneshot标签添加到服务
service Storelog /system/bin/logwrapper /system/bin/store_log.sh 服务Storelog / system / bin / logwrapper /system/bin/store_log.sh
user root 用户根
disabled 残障人士
oneshot 单发
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.