Is it possible to log on a file the reboot cause on a board which runs OpenWrt? In example, if via Putty I send the command "reboot", is it possible to log on a RebootLog.txt file the cause? (in example, in this case will be "manual reboot")
Hope my question is clear enough
Logs under OpenWrt are stored on a "volatile" file system (
/var/ for most OpenWrt devices), primarily as repeated writing to flash memory can cause it to fail very quickly. To persist logs over a reboot, a file system on a device intended for "frequent" writing is recommended, such as a USB "stick". The default logger can, I believe, redirect to a log file. I use
logrotate to manage logs.
If you're only looking to capture an occasional event, you can write to the overlay file system in a directory that is persisted over reboots. I wouldn't recommend anything more than perhaps a line or two a day. A typical SPI flash chip can handle 10,000 - 100,000 cycles (depending on manufacturer) before failures become likely. Ten a day for a year is already a significant fraction of a 10,000-cycle lifespan.