How to reboot router when a string appears in the log

OK, it is not good example, because file is deleted after reboot from /tmp Please, create corresponding file in /etc/config

Thanks a lot.. it works at last.

Here is the output just in case

root@OpenWrt:~# ls -l /etc/rc.d | grep -i pservice
lrwxrwxrwx    1 root     root            18 Feb 20 17:44 S99pservice -> ../init.d/pservice


root@OpenWrt:~# cat /etc/config/pservice
config pservice
        option name 'demo0'
        option command /bin/sh
        list args '/root/phy0-watch.sh'
1 Like

I did, but something was not right. The script was not running at reboot. I must've rebooted many times already just to check that, maybe my script was not correct somehow. Still thanks a lot for your help..

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

OK, I've checked:

tail -f /etc/config/file.txt | while read -r line
do
 echo $line >> /etc/config/file.out
 if [ "$line" = "abc" ]; then
  echo "LINE" >> /etc/config/file.out
 fi
done

root@OpenWrt:/etc/config# cat file.out
12u
23i
root@OpenWrt:/etc/config# echo abc >> file.txt
root@OpenWrt:/etc/config# cat file.out
12u
23i
abc
LINE
root@OpenWrt:/etc/config#

The problem is that command 'reboot' doesn't work, because /etc/rc.local doesn't return 0, to my mind. Try to create another script, and run it from /etc/rc.local:

/etc/config/script.sh &

exit 0
1 Like

Well, guess what... It works... !
I wish i could select multiple answers as solution. Thanks a million

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.