mtb 05 minitab® autojobsminitabmaestro.com/wp-content/uploads/2016/04/mtb-05-autojobs… ·...

27
M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 1 MTB – 05 Minitab® AutoJobs This Module will cover: Prerequisites Overview of the process Folder – home for the AutoJob Startup.mac – the Macro that executes the AutoJob Shortcut to Minitab® for manual execution of the AutoJob Task Scheduler – to have the AutoJob run unattended

Upload: others

Post on 14-Apr-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 1

MTB – 05 Minitab® AutoJobs

This Module will cover:

• Prerequisites

• Overview of the process

• Folder – home for the AutoJob

• Startup.mac – the Macro that executes the AutoJob

• Shortcut to Minitab® for manual execution of the AutoJob

• Task Scheduler – to have the AutoJob run unattended

Page 2: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 2

Prerequisites

Before you tackle this module you

should:

– Have experience capturing commands

from Minitab

– Know how to create & edit Minitab®

global macros

– Be comfortable with the basic Windows®

tasks of creating folders, shortcuts,

copying and moving files, etc.

Page 3: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 3

Overview

To create a Minitab® auto-job you need:

– To do a one time set up of Minitab®

– A macro • which will read the needed data and create the desired

outputs (eg. Graphs saved as JPEG files). (Covered in previous module).

– A dedicated folder for the job• to house the Startup.mac file and the Shortcut to Minitab®

– A Startup.mac file • which calls other macro(s) to execute the needed macro code.

– A Shortcut to Minitab® • for testing and manual execution of the job.

– A Windows® scheduled task• for unattended execution of the macro

Page 4: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 4

One Time Set Up of Minitab®

This set up changes the options for

Minitab on a computer. It:

– Blanks out the default folder for Minitab®

– Turns on the Command Prompt.

• May have been done in previous module.

– Sets the graph size for output JPEG files

so they will display well in a web browser.

Page 5: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 5

One Time Set Up – cont’d

1. Click Tools > Options…

2. Blank out the Default file location:

Page 6: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 6

One Time Set Up – cont’d

3. Expand the Session Windowoptions, click on Submitting Commands and then click the button for Command Language Enable.

Page 7: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 7

One Time Set Up – cont’d

4. Expand the Graphicsoptions, click on Graph Size and then enter the desired True Size of 254 by 177.8 mm or 10 by 7 inches*

5. Click OK to save all your option changes.

* 240 by 165 mm = 9.5 by 6.5” works well if you don’t like going Full Screen with your browser

Page 8: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 8

An example Folder for Auto-Job

This shortcut lets you run the job manually (by double

clicking on the shortcut).

By specifying this folder as the “Start In” folder, when Minitab runs it will look for

this Startup.mac File

You need to create a dedicated folder, in a suitable location, to

provide a home for your AutoJob.

Page 9: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 9

Auto-Job Folders Organization

This collection of folders is a useful way to organize Auto-Jobs:

• In the AutoJobs folder you have sub-folders for each production job.

• The Data folder can be a repository for reference files or other data you access. (Likely most data you access will be in databases).

• The Macros folders can house your “production” macros. If you have a personal macro folder, you can develop and test your personal version of the macro before copying to this folder.

• The Output folder can store the output of your jobs (eg. The JPEG, Excel, Text, CSV or other files). It is a good idea to organize the output into sub-folders for each sub-system you develop (eg. The HOME folder here for home data analysis jobs).

• The Projects folder can be for testing, temporary files, etc.

Note: normally you would set up these folders, especially the output folders, on a shared drive so more than one person can access the output.

Page 10: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 10

The Startup.mac File

Any time Minitab® starts, it looks in the “current” folder. If it sees a Startup.mac

file, it executes it.

We make use of this by having our auto-job “Start In” a specific folder that runs the

code we want executed -- including the code to shut down without interactive input.

Minitab® macros are written in plain text so they can be edited with NotePad, however other editors (such as my

favourite EditPadPro) make the editing job easier. (EditPadPro provides Syntax colouring very powerful search & replace, ability to edit

multiple files simultaneously, a clip collection capability, etc.)

This code is explained in more detail in subsequent slides.

Page 11: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 11

The Startup.mac File cont’d

These comments are useful to stay organized. With each

revision to a “production” macro I add one line to the

change log section

Global macros start with the gmacrostatement followed by the name of the macro

The Note statement is used to output text to the command

window. This can be helpful to follow the progress of a macro

The “heart” of this startup macro is calling the macro which will create the output you want. (You could put all the code in the startup.mac file but it is easier to call a separate file. In fact you can have the startup.mac file call a series of macros).

Page 12: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 12

The Startup.mac File cont’d

This is “clean up” after the macro runs. You must save the project before you exit, otherwise you will be interactively prompted to ask if you want to

save your project. This would stop the automatic execution!!

This closes all graphs before you exit.

This closes the current worksheet. It is a good idea to close worksheets as soon as they are no

longer needed. You don’t want to exit with a worksheet containing data as it will slow down the

exit process and waste disk space.

Page 13: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 13

The Startup.mac File cont’d

These commands are the “secret” behind Minitab® auto-jobs. Without

them, you cannot exit Minitab® without being interactively prompted to ask if

you want to save your project.

You must save the project as part of exiting so this project is saved in a

folder to which you have access. The filename makes it clear that the file

could be deleted!

A more sophisticated

project save if there is the possibility of

overlapping job executions.

Page 14: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 14

Creating the Shortcut to Minitab®

1. Open two Explorer/My Computer windows – one with the Minitab® and one

with your dedicated auto-job folder

2. Right click on the Minitab® Executable

file, then drag and release in the auto-job folder. Select “Create

shortcuts here”

Page 15: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 15

Creating the Shortcut to

Minitab®

Rename the shortcut to be descriptive of

the job

Right Click on the shortcut, choose properties & change the “Start In” folder to be

the dedicated folder for your auto-job. (You can copy &

paste from the address bar).

Page 16: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 16

Creating a Windows®

scheduled task

• Open the Task Scheduler:

– Start > Accessories > System Tools > Task Scheduler

• Create a Scheduled Task to Run Minitab® with an appropriate “Start In” folder.

– Note: The Windows 7 Task Scheduler is shown. The approach is similar with other versions of Windows but the interface is different.

4

3

2

1

Page 17: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 17

The Task Scheduler

A Listing of the

currently Scheduled

TasksCreate Basic Task will be used to set up the Minitab®

auto-job.

Each tab provides information on the

Selected Task

Page 18: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 18

Creating a Windows®

scheduled task - cont’d

Enter a suitable name

Optional description of job

On to Triggers!

Page 19: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 19

Creating a Windows®

scheduled task - cont’d

Select a suitable trigger frequency

Page 20: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 20

Creating a Windows®

scheduled task - cont’d

Select Start Time (Needed since we

selected Daily)

Page 21: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 21

Creating a Windows®

scheduled task - cont’d

Minitab® is the program we will start

Page 22: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 22

Creating a Windows®

scheduled task - cont’d

Browse to the Minitab® executable

file and “Open” it.

You must specify the “Start In” folder as the folder with your StartUp.mac file for

this job.

HINT: You can copy & paste the path from the address bar of an Explorer / My Computer window.

Page 23: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 23

Creating a Windows®

scheduled task - cont’d

Click this box as there is one more setting to specify

Page 24: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 24

Creating a Windows®

scheduled task - cont’d

Click the Settings tab and then select a

suitable time for “killing” the job should it still be

running. This is helpful in cases where job stalls with an error (e.g. a

database you are trying to access is unavailable).

If too many jobs stall and are not killed, the PC

will hang.

Page 25: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 25

Creating a Windows®

scheduled task - cont’d

From the task scheduler main window you can right click on a job and choose “Run” to have it run immediately (e.g.

to test it or to rerun it if the job failed earlier – perhaps because a

database was temporarily unavailable).

Your job is now scheduled to execute daily.

Celebrate!!(Optional but highly recommended).

Select “Properties” if you want to revise the settings for your job.

Page 26: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 26

Next Steps

• Once you have AutoJobs creating output you likely want to take some additional steps (covered in subsequent training modules):

– Monitor the execution of the AutoJobs to ensure they are operating as expected

– Set up a Web Site to facilitate access to the output of the AutoJobs. You could just navigate to the folders containing the outputs but a Web Site does a much better job of organizing the outputs.

Page 27: MTB 05 Minitab® AutoJobsminitabmaestro.com/wp-content/uploads/2016/04/MTB-05-AutoJobs… · Minitab® macros are written in plain text so they can be edited with NotePad, however

M. A. Sibley Consulting – All Rights Reserved MTB 05 – AutoJobs 27

Review

What where the steps?

1. Do a one time set up of Minitab®

2. Write a macro which will read the needed data and create the desired outputs (eg. Graphs saved as JPEG files). This was covered in the previous module.

3. Create a dedicated folder for the job to house the Startup.mac file and the Shortcut to Minitab®

4. Create a Startup.mac file which calls the macro(s) you created in step 1.

– This macro contains the “secret” commands to exit Minitab® without being prompted to save the project, etc.

5. Create and modify a Shortcut to Minitab® for testing and manual execution of the job.

6. Create a Windows® scheduled task for unattended execution of the macro