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"

Thanks for reading! And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.

Chris Hulbert

(Comp Sci, Hons - UTS)

Software Developer (Freelancer / Contractor) in Australia.

I have worked at places such as Google, Cochlear, Assembly Payments, News Corp, Fox Sports, NineMSN, FetchTV, Coles, Woolworths, Trust Bank, and Westpac, among others. If you're looking for help developing an iOS app, drop me a line!

Get in touch:
[email protected]
github.com/chrishulbert
linkedin



 Subscribe via RSS