Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to save my crontab output:

15 * * * * myscript.sh > ~/logs/log1.txt

How do i make the crontab save to a new file everytime (i.e. log2.txt, log3.txt etc.) , instead of updating or overwriting the old one?

Perhaps there's a utility i could use to do this?

I'm using CENT OS 5.

Thanks ;)

share|improve this question
2  
Have a look at unix.stackexchange. –  binfalse Apr 26 '11 at 11:08
add comment

2 Answers

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
share|improve this answer
add comment

You could use the date and time to make a unique file name

15 * * * * myscript.sh > ~/logs/log.$(/bin/date +\%Y\%m\%d\%H\%M\%S).txt

This will create files named like ~/logs/log.20110426121501.txt

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.