0

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.

  • Can you clarify 'not working'. What is the error message/problem that you observe ? – dash-o Nov 10 '19 at 09:49
  • @dash-o, Thanks for the help. Updated the details. Please take a look. – Ayush Laad Nov 11 '19 at 12:13
  • Consider checking the the folder '/data/local/tmp/test' with the correct permission for the daemon account to use. There might be an error message from mkdir. Better to use 'mkdir -p' to check/create the folder. – dash-o Nov 11 '19 at 15:21

1 Answers1

0

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.