Init.rc : service killed and restarts

1.7k views Asked by At

I'm running shell script in init.rc as a service but it killed and restarts continuously.

Service registering in init.rc as follows

service Storelog /system/bin/logwrapper /system/bin/store_log.sh
user root
disabled

and script store_log.sh is

#!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

This service starts, after one loop its killed and restarted.

What I am missing here ?? some permission ?? Any suggestion are helpful.

2

There are 2 answers

1
user3629249 On

according to this page: http://developer.android.com/tools/help/logcat.html

the '-c' option causes logcat to exit

however, by then, the 'kill' has already exited 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
0
headfirst On

you can try to add oneshot tag to the service

service Storelog /system/bin/logwrapper /system/bin/store_log.sh

user root

disabled

oneshot