Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

In crontab, I scheduled a daily backup script. Now when the cron executes the script the status are logged to a log file as shown below.

0 0 * * * /home/backup.sh > /home/groupz/db-backup/fbackup.log 2>&1  

Now, when the cron executes a script the contents of the log get renewed everytime. So, I want the contents to be added to the same file with time stamp of the executed time and below the contents of each time along with the existing contents. How can I do this.

share|improve this question

marked as duplicate by Anthon, slm, Karlson, Joseph R., jasonwryan Dec 16 '13 at 16:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
That other question seems to be the opposite, and also not answer the timestamp part. –  derobert Dec 16 '13 at 16:14

2 Answers 2

The problem is >, you should use >> to append to the file.

share|improve this answer

0 0 * * * /home/backup.sh >> /home/groupz/db-backup/fbackup.log 2>&1 will solve the problem

>> will append the file

> will overwrite the file

share|improve this answer
    
+1 for explaining the difference (and the corrected crontab entry). –  Alexios Dec 16 '13 at 14:06

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