Reputation: 12403
I'm trying to create a log file of a bash script that is run with the data. I currently have this:
bash script.sh > /var/log/%Y-%m-%d_%H:%M.log
The problem is the log file actual writes %Y-%m-%d_%H:%M and not the date. Is there way to get the date to actually write out the date by only running it in the console?
Upvotes: 10
Views: 19467
Reputation: 298206
Pass that string to date
:
bash script.sh > "/var/log/$(date +%Y-%m-%d_%H:%M).log"
Upvotes: 21