Site Tools


ash_history

This is an old revision of the document!


By default the command line history is kept as long as you don't reboot or power off your router. It is possible to make it persistent by using permanent storage like JFFS or a USB attached storage.

The commands history is kept in /tmp/home/root/.ash_history

We can use FreshTomato ability to execute script at boot and at shutdown to backup and restore the commands history to make it persistent across reboots. To do so, we need 2 scripts. One that will execute on shutdown to backup the history to permanent storage and another one to restore the history on boot.


This shutdown script will save the last 100 used commands. If you want to keep more, change '100' with the number of your choice. Name your backup script cli_history_save.autostop and use the following code:

cli_history_save.autostop
#!/bin/sh
 
tail -n 100 /tmp/home/root/.ash_history > ${1}/.ash_history


The second script will restore the history when booting.
Name your restore script cli_history_restore.autorun

cli_history_restore.autorun
#!/bin/sh
 
cp -f ${1}/.ash_history /tmp/home/root/.ash_history


Make sure to place the scripts in the storage mount directory, i.e. /jffs for JFFS or /tmp/mnt/sda1 for USB (replace 'sda1' with the name of the partition). Also make the scripts executable with chmod.

chmod +x cli_history_save.autostop cli_history_restore.autorun
ash_history.1727137691.txt.gz · Last modified: 2024/09/24 01:28 by hommeoursporc