BookmarkSubscribeRSS Feed
pcapazzi
Pyrite | Level 9

How can one get a list of a campaigns that are scheduled to be executed during the next __ hours? 

6 REPLIES 6
JamesAnderson
SAS Employee
Hi pcapazzi,
Within CI Studio there isn't a way to do this.
It would be technically possible to query the SAS metadata server to get the campaign objects, and then parse them to see what Schedule has been set, but the easier (and actually the only reliable and precise) way to do this is to "ask" the scheduling software.
If you are using Windows OS scheduler - "schtasks /query" at the command line will give you a list you can parse (and other schtasks parameters can help filter the list)
If you are using LSF, then "jdefs -l -u {scheduling user}" will give you a list of jobs you can parse to create a succinct list.
Let me know if you are using LSF and I can share some code I wrote to parse the output into a data set.
Cheers
James
Dmitry_Alergant
Pyrite | Level 9

Hi James and pcapazzi, 

 

Assuming the client uses LSF (which in my experience is more often that they have it with SAS MA rather than not), I'd also suggest just looking visually in the Process Manager client (Flow Manager) - Global Definitions view.   It's not clear from the request whether they actually need to query it programmatically - maybe a visual inspection should suffice?

 

-------
Dmitriy Alergant, Tier One Analytics
pcapazzi
Pyrite | Level 9

We use LSF.

 

Ultimately, I want to avoid missing campaign executions because the server had downtime for maintenance. If we expect the server to be down I want to identify what we need to reschedule to run earlier or simply wait until the server is back online. 

 

I 'd like to understand how to get the data programmatically (just my nature). If the visual gives campaign name or codes that may be sufficient. 

 

FYI - I did search for LSF commands and could not find one that tells me the date and time of the next run or the details of the scheduling (ex: weekly every Saturday at 2pm). I did try Flow Manager and did not see anything in there that seemed to fit. The closest I saw was to create a new calendar that was a consolidation of other calendars as I want a holistic view. I'm curious what I missed in there. 

 

Thanks.

Dmitry_Alergant
Pyrite | Level 9

Try looking for a so-called "Global Definitions View" there. 

 

I don't remember where exactly is the button to get there, but it exists.

 

Screen Shot 2018-07-06 at 01.55.41.png

-------
Dmitriy Alergant, Tier One Analytics
JamesAnderson
SAS Employee
If your Process Manager server is on a different host to your MA servers, then you do have the option of setting the LSF queue which runs your campaigns to be OPEN and INACTIVE. This will allow scheduled campaigns to be submitted to the queue at the normal time, but not execute (they will just sit there in PM waiting). When your MA server(s) come back online, you can ACTIVATE the queue, which would allow the campaign to then begin executing. This could even work if PM is on the same host as MA, providing you are able to leave PM running.
However, to go back to your question about getting a list, jdefs will produce a job listing that includes the last and next time of execution. I've highlighted the interesting parts in red.
C:\Users\sas>jdefs -l
User name: .\lsfadmin
Password:
NAME: _CAMP1303
-- 2015 Marketing campaign CI\Financial Services\CI Business Context\Campaigns\Outbound\MOM-MA Starts Friday, July 6, 2018 2:00:00 AM EDT Recurs every 1 day(s) Ends after 1 occurrences

USER STATUS FLOW_IDS
.\lsfadmin Release

DEFAULT VERSION: 1.0
LATEST VERSION: 1.0

Triggering Events :

Last Event: None
Next Event: Fri Jul 06 02:00:00 GMT-04:00 2018
Exit Condition:
All jobs completed successfully.

The trick here is that jdefs requires a user and password to be provided interactively. So you need to write a script to do this. On Linux you can use the EXPECT command:
getJobDefs.sh
#! /bin/sh

/usr/bin/expect <

spawn jdefs -l -u $1
expect "User name:"
send "lsfuser\r"
expect "Password:"
send "myPassword\r"
expect eof

EOD
Then with some good 'ol BASE SAS, pipe filename and some string parsing you can put this data into a dataset.
%MACRO GetJobDefs(User) ;
filename jdefcmd pipe "&ScriptDir/getJobDefs.sh &User";

data jdefs_tmp (drop= jdefstr LastEvent NextEvent);
format jdefstr $1000.
FlowName $50.
JobStatus $20.
User $50.
LastEvent $35.
LastRun Datetime19.
NextRun Datetime19.
Trigger $200. ;
infile jdefcmd lrecl=1000 truncover ;
input @1 jdefstr $1000. ;
retain FlowName JobStatus User LastRun NextRun Trigger ;

if jdefstr =:'NAME:' then do ;
FlowName=substr(jdefstr,7) ;
JobStatus = '' ;
LastRun = '' ;
NextRun='' ;
Trigger='' ;
end;

if jdefstr =: "&User" then do;
JobStatus = scan(jdefstr,2,' ') ;
User = "&User" ;
end;

if jdefstr=: '<' then do;
Trigger = scan(jdefstr,1, '<>');
end;

if jdefstr =: 'Last Event' then do;
LastEvent = CATT(substr(jdefstr, index(jdefstr,':')+1));
if INDEX(LastEvent, 'None') = 0 then do;
LastRun = input(CATX(' ', CATT(scan(LastEvent,3), scan(LastEvent,2), scan(LastEvent,-1)), scan(LastEvent,4)), Datetime19.) ;
end ;
end;

if jdefstr =: 'Next Event' then do;
NextEvent = CATT(substr(jdefstr, index(jdefstr,':')+1));
if INDEX(NextEvent, 'None') = 0 then do;
NextRun = input(CATX(' ', CATT(scan(NextEvent,3), scan(NextEvent,2), scan(NextEvent,-1)), scan(NextEvent,4)), Datetime19.) ;
end ;
output ;
end;
run;
%MEND ;
%
/* get history and jobs for all users */

%GetJobDefs(all);
Cheers
James
pcapazzi
Pyrite | Level 9
jdefs is not in my path. I found it in the scheduler/js/9.1 folder but when I try to run it there is an error /etc/js.conf does not exist. What you have in code looks like what I'm after though.
I found the Universal View. That may help but it's not very straightforward. I was hoping for something that would present what going to execute in a calendar view
How to improve email deliverability

SAS' Peter Ansbacher shows you how to use the dashboard in SAS Customer Intelligence 360 for better results.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1509 views
  • 0 likes
  • 3 in conversation