0

Hi I have the following command that does yui optimizations and runs as a cron job. I want to log the output of the command to a log file.

find . -type d -exec bash -c "cd '{}' && pwd && java -jar /opt/yui/yui.jar -o '.css$:.css' *.css" \; > log

This command logs the output of find but not the output of yui.jar. that is logged to the console. Any way to log that to the same file ?

remudada
  • 57
  • 8

2 Answers2

1

This command logs the output of find but not the output of yui.jar.

You will need to redirect the output then, something like

 ...java -jar /opt/yui/yui.jar -o '.css$:.css' *.css >logfile 2>errorlog ...
user9517
  • 115,471
  • 20
  • 215
  • 297
0

If you want to log both the "yui.jar" output and the "find" one, you have to add the redirect in quotation marks, like this:

find . -type d -exec bash -c "cd '{}' && pwd && java -jar /opt/yui/yui.jar -o '.css$:.css' *.css >> log" \; >> log

and maybe you want to specify a different name for the log file other than "log"...

Igor Bosi
  • 1
  • 1
  • 1
    Won't redirecting both to the same file cause data loss? – chicks May 31 '16 at 12:56
  • The command indeed causes data loss. The log file that gets created only has the output from the main command, not the result from yui.jar – remudada Jun 02 '16 at 10:59