Saturday, 10 December 2016

Run task scheduler in command line

schtasks is used to create/run tasks in command line without the need to open "Task scheduler".

I've tried query and run parameters but not yet for create.

It is required to provide the task name including the folder that task is created in.

To query if a task exists
 >schtasks /query /tn "thelog"  
 ERROR: The system cannot find the file specified.  
 >schtasks /query /tn "Microsoft\thelog"  
 Folder: Microsoft  
 TaskName                 Next Run Time     Status  
 ======================================== ====================== ===============  
 thelog                  N/A          Ready  
 >schtasks /query /tn "Microsoft\the special log"  
 Folder: Microsoft  
 TaskName                 Next Run Time     Status  
 ======================================== ====================== ===============  
 the special log             N/A          Ready  

To run the task
 >schtasks /run /tn "Microsoft\thelog"  
 SUCCESS: Attempted to run the scheduled task "Microsoft\thelog".  
 >schtasks /run /tn "Microsoft\the special log"  
 SUCCESS: Attempted to run the scheduled task "Microsoft\the special log".  

It is needed to run tasks in elevated command prompt though.

IBM DSA utility to collect logs

A few command line switches can be used together with dsa to collect logs in different format.

When the executable is run without any parameters, it would save the log in XML format.

> ibm_utl_dsa_dsyte1d-9.61_portable_windows_x86-64.exe

To generate it in HTML format, -v must be used.

> ibm_utl_dsa_dsyte1d-9.61_portable_windows_x86-64.exe -v

To convert the log generated in XML to HTML format, the following command is used.
> ibm_utl_dsa_dsyte1d-9.61_portable_windows_x86-64.exe -v -x -i generated_log.xml.gz

To compare current log with previously collected one, -r switch with log files names together is used. Both logs must be generated using same version of DSA though.
> ibm_utl_dsa_dsyte1d-9.61_portable_windows_x86-64.exe -r generated_log_001.xml.gz generated_log_001.xml.gz -v