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 am setting up rsync cron to run every hour to sync up 2 servers. My question is how do I make the log file name that it is saving to in the format log_file-{Year}-{Month}-{Date}.log with the year, month, and date changing accordingly?

Thanks in advance.

share|improve this question

1 Answer 1

I assume you're using --log-file? Then you can do something like this:

date=`date +%Y-%m-%d`
rsync --log-file=log_file-$date (...)

Or, in a single line if you're putting this directly in your crontab:

rsync --log-file=log_file-`date +%Y-%m-%d` (...)
share|improve this answer
    
Based on what I see from the system cron log, this is what is being ran rsync -av --log-file=/home/backup/rsync/rsync-`date +. Looks like it is hanging up on the + –  Tom May 31 '11 at 18:48
1  
Try this: rsync --log-file=log_file-$(date +%Y-%m-%d) (...). You're probably better off creating a backup.sh and putting the whole procedure there - it's cleaner and lets you move to a more complex or multi-step backup procedure easily. –  Eduardo Ivanec May 31 '11 at 18:58

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.