DOS for command will not output log file

January 4, 2011 at 14:26:25
Specs: Windows Server 2003
I have a batch file that is a for command. When I exucute it from task scheduler I can't get it to output to a log with my normal method"

IndexSplit.bat contains
for %%x in (E:\Filer\Input\MultiFileIndex\*.idx) do D:\Tools\Scripts\CTxt %%x

and is executed from Task Schedulr with
D:\Tools\Scripts\IndexSplit.bat >> IndexSplit.log 2>&1

but IndexSplit.log is not created, and when I create it manually, the job does not write to it. What I am doing wrong?

See More: DOS for command will not output log file

Report •

January 4, 2011 at 14:38:43
Change this...

for %%x in (E:\Filer\Input\MultiFileIndex\*.idx) do D:\Tools\Scripts\CTxt %%x


for %%x in (E:\Filer\Input\MultiFileIndex\*.idx) do D:\Tools\Scripts\CTxt %%x >> c:\IndexSplit.log

I don't think you can use redirection in task scheduler.

Also what is this for...


Why do you have it at the end of your batch execution?

Report •

January 4, 2011 at 18:07:45

Thanks for responding so quickly. Actually you can redirect from Task Scheduler, the trick was to use the full path in the log... so in Task Scheduler I used:

D:\Tools\Scripts\IndexSplit.bat >> D:\Tools\Scripts\IndexSplit.log 2>&1

and it finally worked

2>&1 Redirects both standard output and standard error to the same file, and must be at the end of the line/command

Report •
Related Solutions

Ask Question