how to make scheduler backup command history every restart ?
i try with
@reboot history > backup.txt
and I reboot my pc there is a file backup.txt in directory but the file is empty, there are no results of the command history
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
history doesn't work that way. Read this link for more information.
A direct quote from the link above:
Bash maintains the list of commands internally in memory while it's running.
Since Bash is not running after a reboot, you get no output.
cron does not use the same
PATH as your Bash shell does. More on that here.