Answer the question
In order to leave comments, you need to log in
Why is print() from lua not getting logged?
There is a very simple lua script that periodically calls a function containing print().
If I run the script as /usr/bin/lua5.1 /home/mqtt/client.lua
, everything is fine - what print() produces is printed to the console.
If I write a wrapper for sh like
cd /home/mqtt
/usr/bin/lua5.1 /home/mqtt/client.lua 2>&1
and run it as ./fmp_client.sh, everything is fine too. cd /home/mqtt
/usr/bin/lua5.1 /home/mqtt/client.lua >> /home/mqtt/log/client.log 2>&1
cd /home/mqtt
/usr/bin/lua5.1 /home/mqtt/client.lua >> /home/mqtt/log/client.log
Answer the question
In order to leave comments, you need to log in
I just tried a simple script at home, it worked.
I can advise to replace print() with io.write() and/or remove buffering io.stdout:setvbuf("no")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question