I changed directory name of my log file to include $$ (pid) of the bash script. If I add $$ to the directory name, the following expression fails to execute.
command $@ >> $log 2>> $log;
#Initial line that works
log="$work/$1";
#Modified with $$ - didn't work
log="$work/$$/$1";
$work/$$directory exist before you run that?