Shell history not work

In 25.12.0 release announment, It says:

Shell history is preserved
Shell command history is now preserved across sessions by storing it in a RAM-backed filesystem.

Benefits:

Command history is no longer lost between logins
No unnecessary writes to flash storage by default
For users who prefer persistent history storage, this behavior can be changed by editing: ''/etc/profile.d/busybox-history-file.sh''

:warning: Note: Storing history on flash will increase write cycles and may impact flash endurance over time.

But it seams not work. I checked /etc/profile


[ -n "$FAILSAFE" ] || {
        for FILE in /etc/profile.d/*.sh; do
                [ -e "$FILE" ] && . "$FILE"
        done
        unset FILE
}

So it has to be in failsafe mode to make it work ?

How reboot to failsafe mode ?

No that is not necessary

But when you are done you have to do exit to preserve your history (on most routers that is)

2 Likes

Thanks, that works. So I have to `exit ssh to save hist to file.

Yes indeed
It is a busybox setting (Save on exit) but that is only configurable if you make your own builds

Yes, but it does not survive a reboot as it is written to /tmp and that is in ram, not flash.

You can make it permanent as described in the 25.12.0 release notes:

Basically edit /etc/profile.d/busybox-history-file.sh to point to persistent storage instead of /tmp or /var (which by defaults points to /tmp on OpenWrt).

4 Likes

Yes, and it can be very useful for debugging, particularly when investigating what things that cause reboots or crashes/lockups.

BUT The very next line after the one you quoted from your link says:

:warning: Note: Storing history on flash will increase write cycles and may impact flash endurance over time.

For the benefit of others reading this thread:
It is not a matter of "may impact flash endurance", but more like "WILL impact flash endurance".
Verbose logging can destroy a flash chip in as little as weeks. If you are lucky it might take months.
If you are VERY lucky it might take years.
If you want to have permanent non-volatile logs, you should use a usb memory stick.
A damaged memory stick is just a PITA.
A damaged flash chip on your router is a catastrophic failure.

4 Likes

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