Oct 29
Hi again,
When setting up scheduled tasks to run on an windows server, i've found it useful to wrap my executable with a batch file, which keeps track of logging all the console standard and error output. It redirects them to log files with a YYYYMMDD prefix, and deletes old logs too. The idea is that the scheduled task runs this batch instead of the executable directly:
md logs echo ************************ >> logs\%date:~10,4%%date:~7,2%%date:~4,2%_MyJob.log echo Starting - %date% %time% >> logs\%date:~10,4%%date:~7,2%%date:~4,2%_MyJob.log MyJob.exe >> logs\%date:~10,4%%date:~7,2%%date:~4,2%_MyJob.log 2>&1 echo Ended - %date% %time% >> logs\%date:~10,4%%date:~7,2%%date:~4,2%_MyJob.log echo ************************ >> logs\%date:~10,4%%date:~7,2%%date:~4,2%_MyJob.log rem *** Clean up 60 day old logs Forfiles -p logs -m *.log -d -60 -c "cmd /c del @path"
