Search code examples
androidshelldebuggingloggingtmp

Unable to log into file using logcat running from script as a service in AOSP 5.1


I am trying to log to a file from custom shell script started as service using init.project.rc. On using below lines in the script(ethmon.sh), i am unable to log it to file test.txt. It is not even creating the file. Any hints on this?

ethmon.sh

    mkdir /data/local/tmp/test 2>/dev/null
    echo "Issue Observed with IP at `date`" >> /data/local/tmp/test/test.txt
    dmesg >> /data/local/tmp/test/test.txt
    timeout -t 10 logcat -v time -f /data/local/tmp/test/logcat.txt

init.project.rc

service ethmon /system/xbin/ethmon
    class main
    user root
    group root
    oneshot 
on property:dev.bootcomplete=1
    start ethmon

preload_script.sh

cp -f $SOURCE_FOLDER/ethmon.sh $OUT/system/xbin/ethmon

I am new to aosp, am i missing some permissions to be added for this.

NOTE: Other lines of code(ifconfig eth0 down/up, netcfg) is working fine in the same script.


Solution

  • Finally i added selinux permissions and created .te file for my service to get the log thing working. Thanks https://stackoverflow.com/users/12098405/dash-o for the help. People with same issue can comment for any further information.