我想保存我的crontab输出:
15 * * * * myscript.sh > ~/logs/log1.txt
我如何使crontab保存到一个新的文件(即log2.txt,log3.txt等),而不是更新或覆盖旧的?
也许有一个实用工具,我可以用来做到这一点?
我正在使用CENT OS 5。
谢谢 ;)
您可以使用date和时间来创build一个唯一的文件名
15 * * * * myscript.sh > ~/logs/log.$(/bin/date +\%Y\%m\%d\%H\%M\%S).txt
这将创build名为~/logs/log.20110426121501.txt
if you can't use the date as answered by Iain from your script output a watermark like ### this is what I have into test.txt ### test ### test1 then to process it shell$ awk -F "###" {'print $1'} test.txt test test1 i have the delimiter changed from ' ' into awk to '###' and then just print the lines