如何透過crontab將linux中的歷史指令複製到另一個文件

如何透過crontab將linux中的歷史指令複製到另一個文件

我正在使用此命令來複製新命令,但這些命令在 centos 6.5 中對我不起作用

*/1 * * * * ~/.bash_history >> historylog.txt

或者

*/1 * * * * .bash_history >> historylog.txt

或者

*/1 * * * * history | grep -v history >> history.txt

我怎樣才能做到這一點 ?如果我需要任何其他設置,例如 ~/.bashrc 檔案?

答案1

您需要使用命令來列印文件的內容。

所以它會是:

*/1 * * * * cat ~/.bash_history >> historylog.txt

相關內容