<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to retrieve status of schedulered jobs in Administration and Deployment</title>
    <link>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/784944#M23504</link>
    <description>&lt;P&gt;Thanks so much! It was exactly what I was looking for&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Dec 2021 17:11:00 GMT</pubDate>
    <dc:creator>viswmmo</dc:creator>
    <dc:date>2021-12-08T17:11:00Z</dc:date>
    <item>
      <title>How to retrieve status of scheduled jobs</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/784321#M23490</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;
&lt;P class=""&gt;Do you know if there is a way to get a list of last day's scheduled job and their status. That is, in the same way as you can see in the job monitoring tab in Environment Manager, but as a list for further processing. In order e.g. to build a data set of which jobs usually go wrong or to send alerts with failed jobs in the last 24 hours, etc.&lt;/P&gt;
&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;We are using SAS Viya 3.5 running on Linux Rhel 7&lt;/P&gt;
&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;Regards&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;Mattias&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 18:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/784321#M23490</guid>
      <dc:creator>viswmmo</dc:creator>
      <dc:date>2021-12-06T18:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve status of schedulered jobs</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/784359#M23493</link>
      <description>&lt;P&gt;You could query the same endpoint that Environment Manager does using PROC HTTP in SAS Studio, reading the JSON response into a data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Specify the URL for the environment. */&lt;BR /&gt;%let baseurl=https://viya.example.com;
&lt;BR /&gt;/* Define a macro */
%macro getjobs();
&lt;BR /&gt;/* Initialize files */
filename headout;
filename headout temp;
filename resp;
filename resp temp;
&lt;BR /&gt;/* Call the jobExecution REST API using whatever filter you want to limit the results (this one is from Nov 28th - Dec 7th)  */
proc http oauth_bearer=sas_services url="&amp;amp;baseurl/jobExecution/jobs?start=0%nrstr(&amp;amp;limit)=20%nrstr(&amp;amp;filter)=and(ge(creationTimeStamp,%272021-11-28T05:00:00.000Z%27),lt(creationTimeStamp,%272021-12-07T05:00:00.000Z%27))" out=resp headerout=headout HEADEROUT_OVERWRITE;
    headers "Accept"="application/json";
run;
&lt;BR /&gt;/* Read in the response using the JSON libname engine. */
libname resp;
libname resp json fileref=resp;
&lt;BR /&gt;/* Define a data set with the information we want. */
data work.jobs;
	stop;
	length name $ 255 state createdBy $ 50;
run;
&lt;BR /&gt;/* Check for a next link (meaning there are more results not in the initial response) */
data _null_;
    set resp.links;
    if rel="next" then call execute('%let next=%nrstr('||href||')');
run;
&lt;BR /&gt;/* Add the current response into the data set. */
proc sql;
	insert into work.jobs select a.name,b.state,b.createdBy from resp.items_jobrequest as a,resp.items as b where a.ordinal_items = b.ordinal_items;
quit;
&lt;BR /&gt;/* If we found a next link, call it and add its results into the data set, looping until there is no next link. */
%do %while (%length(&amp;amp;next)&amp;gt;0);
	filename resp;
	filename resp temp;
	proc http oauth_bearer=sas_services url="&amp;amp;baseurl&amp;amp;next" out=resp headerout=headout HEADEROUT_OVERWRITE;
	    headers "Accept"="application/json";
	run;
	libname resp;
	libname resp json fileref=resp;
	proc sql;
		insert into work.jobs select a.name,b.state,b.createdBy from resp.items_jobrequest as a,resp.items as b where a.ordinal_items = b.ordinal_items;
	quit;
	%let next=;
	data _null_;
	    set resp.links;
	    if rel="next" then call execute('%let next=%nrstr('||href||')');
	run;
%end;

%mend getjobs;

%getjobs();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Dec 2021 18:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/784359#M23493</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2021-12-06T18:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve status of schedulered jobs</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/784944#M23504</link>
      <description>&lt;P&gt;Thanks so much! It was exactly what I was looking for&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 17:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/784944#M23504</guid>
      <dc:creator>viswmmo</dc:creator>
      <dc:date>2021-12-08T17:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve status of schedulered jobs</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/864472#M26220</link>
      <description>&lt;P&gt;I tried this code but table resp.items_jobrequest not creating&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 08:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/864472#M26220</guid>
      <dc:creator>shkmap</dc:creator>
      <dc:date>2023-03-16T08:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve status of schedulered jobs</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/864543#M26226</link>
      <description>That suggests that there are no jobRequests within the filter range provided, or none you have permission to see. We are using the sas_services oauth token, are you running in SAS Studio? Did you update the baseURL?</description>
      <pubDate>Thu, 16 Mar 2023 14:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/How-to-retrieve-status-of-scheduled-jobs/m-p/864543#M26226</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2023-03-16T14:04:34Z</dc:date>
    </item>
  </channel>
</rss>

