BookmarkSubscribeRSS Feed
NNguyen
Calcite | Level 5

Hi,

Just wondering if there is an option to send sas logs in LSF if job failed?

I cant see any option to attached logs when setting the e-mail notification.

 

Thanks,

 

3 REPLIES 3
SASKiwi
PROC Star

Unfortunately, from what I see, there is no option to do this. The email notification is pretty basic and it doesn't look like you can customise them.

ErikLund_Jensen
Rhodochrosite | Level 12

As far as I know there is no option to send the log as mail attachment. If you want to do it, you need to code something yourself.

 

Logfiles tend to be big, so it might be better to send a mail with the path/name of the logfile in case of errors, but if you code it yourself, you could also read the current log, write it to a temp file in your working directory and attach that to the email.

 

The idea is to write a macro with some code to check the current syscc-value in the job. If syscc = 0 (or < 4, if you want to be notified of warnings as well) then send an error mail with the jobname, syscc value and logfile name. Instead of coding the recipient in the macro it could be made dynamic by defining the recipient in an environment variable in your SAS Batch environment.

 

You can get the jobname and logfile name like this:

 

%let CurrentJob = %scan(%scan(%sysget(LSB_JOBNAME),4,%str(:)),1,%str({));
%let CurrentLog = %sysfunc(getoption(log));

 

If your SAS environment is SAS Grid with ARM logging enabled, it needs some more code, because the SAS Log option returns a partial logname without timestamp. I could supply code to circumvent that by getting the start time from OS and search for a log file created within some seconds after start time.

 

The macro can be called from the autocall libhrary in several ways. If you call the macro in a -TERMST option, it would work without any modification of the jobs, but you need to find the proper place to add the _TERMSTMT option to the SAS call in your batch environment. Depending on the SAS software you use it might be somewhere the server plugin in Management Console.

 

You could also add the macro call to all jobs. Add a macro call to the end of your job files or - in case of DI Studio jobs -  create a user-written transformation with the macro call and add it as the last transformation in all jobs and redeploy the jobs. That would be a lot of work if your jobs are counted in thousands.

 

We do a similar thing at my work with some 4500 jobs in daily batch, only instead of sending emails, we write runtime information to a data base and have a small application, where we can monitor batch progress and browse log files for all finished jobs.

Quentin
Super User

Agree, I think you have to code this yourself.  I have a macro that scans the current log file.  If it finds errors/warnings/bad notes, it emails me.  It also writes job metadata /status to a database table.  So I have a nightly job that checks that table to make sure all expected jobs ran without errors.


Tricia Aanderud has a blog post about how to log-scan end email the results:

https://bi-notes.com/sas-eg-check-the-log/

It's written for EG, but general process works for any SAS job/environment.

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 975 views
  • 0 likes
  • 4 in conversation