Captain Claptrap
Captain Claptrap

Reputation: 3949

linux redirector to log filename with $date variable

I have a script with a line:

ruby /root/backup_scripts/new_scripts/aapxen01.rb>>/volumes/backups/aapxen01/$date.log  2>&1

This produces a log file named ".log", obviously not what I'm looking for. How do I do it to produce the current date as the filename?

Upvotes: 2

Views: 6943

Answers (2)

MarcH
MarcH

Reputation: 19756

Avoid backquotes and use this instead: $(date '+%Y-%m-%d') http://mywiki.wooledge.org/BashFAQ/082

Upvotes: 3

icyrock.com
icyrock.com

Reputation: 28598

Replace $date with:

`date "+%Y-%m-%d"`

Upvotes: 9

Related Questions