views:

7

answers:

1

The following command, run either from cron or the prompt, does not make the expected log. I expect to get a log with the date as the file name. I am able to do this in Windows by using %date% and it makes the date the filename. What am I doing wrong here.

/root/backup_scripts/new_scripts/test.sh>/root/backup_scripts/new_scripts/$date.log 2>&1
+1  A: 
/root/backup_scripts/new_scripts/test.sh > "/root/backup_scripts/new_scripts/$(date).log" 2>&1
Alberto Zaccagni
I get: "-bash: /root/backup_scripts/new_scripts/$(date).log: ambiguous redirect"
Captain Claptrap
Oops, I added the "", try now :P
Alberto Zaccagni
Wonderful! That's it. That makes for a rather large filename, but it works. Thank you.
Captain Claptrap
You're welcome ^^
Alberto Zaccagni