Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.