• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2693
  • Last Modified:

How to log execution of batch file to text file?

I have a batch file that executes various DOS commands and external
applications (e.g. SCP secure copy program). The batch file is executed on a
schedule by Windows 2000 Scheduled Tasks. I need to capture the output (that
I would see on the screen  if I ran the batch file manually in a Command
Prompt) in a text file for troubleshooting purposes.

Here is a sample from the batch file:

CreateWWWSchedule.Exe
SCP -q -pw XXXX sched_denmark.html xxx@xxx.xxx.com:/xxx/xxx/.
net use n: /d
net use n: \\xxx\wwwroot
copy sched_france.html n:\fr

Thanks
0
lneville
Asked:
lneville
  • 2
1 Solution
 
brianadkinsCommented:

In your scheduled task, you could just change the command line and append ">> path\logfile.txt"

If you do this, you may want to add a few new lines to your batch file such as:

echo.
echo.
echo.
echo ===================================
echo.
echo Script %0 Run on %DATE%  %TIME%
echo.
echo ===================================
echo.
:: then the rest of your batch file


This way, you can easily scan through the log file for specific runs

-Brian Adkins
0
 
_nn_Commented:
Did you already try to schedule something like

cmd /c batch.cmd >>batch.log

You may need to give fullpaths :

cmd /c x:\batch.cmd >>x:\batch.log
0
 
_nn_Commented:
hmmm, not fast enough it seems. Sorry brian :)
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now