Email outcome of launchd jobs?

I used to have a number of cron jobs set up in /var/cron/tabs/root. Since I have postfix turned on in my Mac, I would get emails sent to the local root email account detailing the outcome of these cron events.
So, after "enhancing" my Mac's unix underpinnings to the point of inoperability, I found that an "archive and (re)install the OS" was in order. While I was at it, I decided to go ahead and convert all these cron jobs to launchd events (plist files in /Library/LaunchDaemons) since I was doing massive cleanup/recovery activities anyways.
Now, as an example, one of my old cron jobs ran diskutil as root and verified the boot disk on a weekly basis. I "borrowed" one of Apple's OEM plist files and edited it. The replacement launchd plist file in /Library/LaunchDaemons looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>verifyBootDisk</string>
<key>ServiceDescription</key>
<string>verify boot disk as part of a weekly disk maintenance routine</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/diskutil</string>
<string>verifyVolume</string>
<string>/</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>15</integer>
<key>Minute</key>
<integer>54</integer>
<key>Weekday</key>
<integer>5</integer>
</dict>
</dict>
</plist>
It appears to run okay, as do my other launchd jobs, because I can have Activity Monitor running and two processes, fsck_hfs and DiskManager, launch promptly at 3:54PM on Friday, so I believe that the launchd plist is doing exactly what I want it to do. But, unlike the old days when I was handling it as a cron job, I am no longer getting summary outcome emails sent to the local root email account.
On the other hand, the /etc/periodic/* launchd jobs (where * is daily, weekly, or monthly) are generating these summary outcome emails and sending them to the local root email account.
So, I'm wondering, does anyone know how to make launchd jobs, that are not being launched from within the /System/Library/LaunchDaemons/com.apple.periodic-*ly.plist environments, generate and send a summary outcome email to the local root email account?

My own personal mailserver here is working just fine with authorized users sending and receiving mail to/from internal and external addresses (and I believe that it does NOT work for UNauthorized users, too .
Currently, the periodic jobs are sending my root account summaries of results of the daily/weekly/monthly jobs. My issue is, for launchd jobs that are not handled within the "periodic" launchd environment (for example, my weekly "/usr/sbin/diskutil verifyVolume /" job that runs at a day/time way different than "periodic weekly" does), how might one get the launchd jobs to send notification emails of the outcomes of the various launchd jobs, like cron does? Because when these jobs were managed by cron, I got the notification emails. Now that launchd manages the jobs, I don't.
The lines of interest in my main.cf are pretty close to what you have specified; I'm not convinced that these things would have any bearing on my issue so I would question (totally out of ignorance on my part) how/why lines 91 and 152, which I don't have, will enable launchd on the same computer as is hosting the mailserver to send itself an email. And it'd be my 'druthers to keep line 239 mynetworks_style=host≠subnet, as an overzealous and perhaps misguided antihack tool (I can use host because I make my mail clients tunnel into my mailserver via ssh using -L 2525:localhost:25 and -L 1430:localhost:143 port tunneling directives whether they are internal or external to my LAN, so their remote host is my localhost on my computer running the mailserver so mynetworks_style=host works just fine); plus, the mailserver computer is the same computer running the verifyBootDisk script so such an email notification would never leave localhost and get onto my LAN anyways; so I'd be interested in knowing why changing that to subnet would help. I'll try it maybe this weekend and see what happens, though, nevertheless. Got nuthin' to lose and everything to gain.
Gary's post suggests that periodic and cron have the "notification email" function built into it and that launchd does not, hence, a "wrapper script" that launches the desired executable and pipes the standard output to Mail must be written. (I tried adding a Program Arguments string <string> | mail root</string> to my plist but that didn't do anything). I'll try Gary's suggestion of writing my own homegrown bash script, too, that my /Library/LaunchDaemons/verifyBootDisk.plist will reference (as opposed to it referencing /usr/sbin/diskutil as it does now), with, I envision (and hope), pretty much three lines in it:
#! bin/bash
/usr/sbin/diskutil verifyVolume / | mail root
exit 0
and I'll see what happens with that, too.

Similar Messages

  • Email output of launchd job

    I've setup a job using launchd which runs daily as the root user.  (I'm backup up my files to rsync.net and have followed the instructions at http://www.rsync.net/resources/howto/mac_rsync.html)
    Firstly, how do I send an email of the output to an email address of my choosing?
    Secondly, is it possible to be emailed if the job fails to run?
    Regards,
    Ian

    Hi,
    I tried what you told.Everyting is in place.
    Any suggestions???
    Thanks,
    Saumia

  • BODS 3.1 : How to trigger an email alert for the jobs on BODS server ?

    Hi All.
    I have this request.
    BODS 3.1 : How to trigger an email alert for the jobs on BODS server ?
    We have jobs scheduled on BODS running smoothly and absolutely fine.
    But to check, i am logging into the admin console and check for the jobs status.
    I would like to have an email to be received from BODS after each job is finished.
    It could succuessful. Or it could fail.
    Whatsoever, i wish to receive an email alert as soon as a job is finished.
    Can anyone advise me as to whether this could be made possible.
    And if yes, how this could be done.
    Thanks for your help in advance.
    In BOE CMC / for webi / schedule / we find an option to send email for a job success or a job failure.
    Is there any option similar to that in BODS ?
    Also would like to know :
    how to use the smtp_to or mail_to functions ?
    how to set up the smtp server for this ?
    thanks
    REgards
    indu
    Edited by: Indumathy Narayanan on May 31, 2011 3:47 PM

    Hi.
    Since am new to this BODS. I need some help.
    I already have many jobs which are running absolutely fine.
    And when a job runs, and finishes, am able to see the trace saying
    e.g. :
    Job_abc is completed successfully.
    We got the smtp service activated for our test server.
    and we hae a group email id.
    I have put the details of the smtp server / ip address / and said apply restarted.
    The i created a simple test script as below :
    print (' Before email ' );
    smtp_to('abc@company_name.com', 'Job ' || job_name() ||' on ' || host_name() || ' has FAILED',
    ' the job has failed', 0, 0);
    print('After Email ');
    It does send a email to as per smtp_to whatever email is specified.
    But how to differentiate between a job success
    And a job which has failed.
    I wish to have a mail which says on the subject :
    'Job ' || job_name() ||' on ' || host_name() || ' has completed successfully'
    ==> IF it is a success
    OR
    'Job ' || job_name() ||' on ' || host_name() || ' has failed'
    ==> if it has failed
    How to make the system identify, whether
    to send a success message or a error message whatever
    Could anyone advise.
    thanks
    indu

  • I had to change my user ID because I used my email at my old job and now the old one keeps popping up and I can't sync mu phone or authorize my computer at work to sync my phone. to syn

    I had to change my user ID because I used my email at my old job and now the old one keeps popping up and I can't sync my phone or authorize my computer at work to sync my phone. I have a new user ID and PW that allows me into ITUNES but that old one won't go away. Any help? Thanks

    Hi, you can't change which ID was used to purchase any app. However, you can edit your Apple ID, which may be a better option than using a new id.

  • Email notification for failed Jobs

    Hello,
    We are using Oracle Database 10gR2 (10.2.0.2.0) on AIX 5.3
    How can I setup email notifications for Failed Jobs ?
    Here is what I did:
    1. Setup email and Test mail (working)
    2. Setup email address
    3. Create schedule for notification
    4. Create rule for Failed Job Count and select Send Email
    But when the job fails, I do not get the email
    I think I am missing something here.. Can you please help ?
    Thanks a lot :)

    Hi,
    Does up to the Below Three.. are they working properly..
    1. Setup email and Test mail (working)
    2. Setup email address
    3. Create schedule for notification (Does this working..try to test then go for next step)
    Coming to Step 4:-
    4. Create rule for Failed Job Count and select Send Email
    What do you mean by Failed Job Count .. ??
    what is the Logic you are following to find the latest Failed Job.??
    - Pavan Kumar N

  • EMAIL NOTIFICATION FOR DBMS_SCHDEULER JOB STATUS IN ORACLE 10G

    Hi All,
    I want to configure email notification for the job which is running through BUMS_SCHEDULER in oracle 10g
    Please provide the steps for configuration of the email notification.
    Thanks
    Mak

    Is your problem that you do not know how to send an email from Oracle 10g? If so then you use the UTL_MAIL package.
    Here's an example of calling it as part of a scheduler chain, not strictly what you're asking for but this lets you define success and failure steps and call each one based on the status of previous steps.
    BEGIN
    DBMS_SCHEDULER.CREATE_PROGRAM (
       program_name           =>'prg_Export_Success',
       program_type           =>'PLSQL_BLOCK',
       program_action         =>q'[BEGIN
                                    UTL_MAIL.SEND (
                                       sender      => 'who_its_from',
                                       recipients  => '[email protected]',
                                       subject     => 'subject line',
                                       message     => 'the message',
                                       mime_type   => 'text/plain; charset=us-ascii');
                                    END;]',
       number_of_arguments      => 0,
       enabled                  => TRUE,
       comments                 => 'Email success');
    end;
    BEGIN
    DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
       chain_name      =>  'Export',
       step_name       =>  'stp_EXPORT_SUCCESS',
       program_name    =>  'PRG_EXPORT_SUCCESS');
    END;
    /... then define appropriate rules.

  • Mail app marked an email as junk, missed job opportunity. How can I fix this?

    I pipe my school email to my gmail account, which I use the mail app to view. It usually works nicely, but I was going through my junk folder and noticed I missed a job opportunity because mail app sent it to junk. This has never happened before. I am so frustrated now, and I just want to fix it, or if its a bug, blame it on somebody lol. But seriously, this is unacceptable. I'm out of a much needed job now. Please help before I lose another one!

    Maybe you just need to go to Mail > Preferences > Junk and do some more serious configuring, perhaps using the Advanced options, or at minimum, leaving Junk in your Inbox. Anyway, without seeing the email, it's hard to know why it may have been sent to Junk in the first place--too many links, maybe. (Sorry this happened to you though!)

  • How to Configure Email for a Specific job when its Fails

    Hi
    We have So many jobs running in our HR system and BW systems but with no proper Monitoring Configuration. We have Solution manager 7.0 with EHP latest version with CCMS configured. How to setup the email in Solution Manager using CCMS when Job failed?
    Is there any standard way of doing it from HR system and BW system other than using solution manager? so that we can use it for Temporary solution.
    Thank you for you support
    Regards
    Bhaskar

    Hello Bhaskar,
    I recommend to use SAP CPS by Redwood to schedule you BW and of course also your HR jobs.
    Please check out the following document:
    SAP CPS by Redwood - Increasing the Value of SAP NetWeaver Business Intelligence
    Scheduling
    The monitoring capabilities fo SAP CPS are described in the documentation:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/0a/1a5678b72c418d96242330b96473c6/frameset.htm
    You can use SAP CPS together with SAP Solution Manager free of charge (and even the OEM license for SAP CPS is free of charge). This way you can also combine SAP CPS and Business Process Monitoring in SAP Solution Manager.
    /people/martin.lauer/blog/2009/05/11/process-scheduling-adapter-for-sap-solution-manager-for-everybody
    Kind regards,
    Martin
    Job Scheduling Managment  -  http://service.sap.com/jsm
    SAP CPS                               -  Scheduling

  • Get an email after failure of job in SAP APO

    Hi Experts,
    We are working on SCM 5.1 server. Actually we are trying to get an email if we there is  a failure of job in SM37.
    Do we have any setting to achieve this requirement?
    Thanks in Advance..
    Reg

    Hey Sujay,
    As Alexander suggested process chains is a veru easy option. Explore the option for message processing and you will be able to setup in no time. Just make sure that the necessary email recipients are configured in SAP (Tx SCOT) to receive emails under the SMTP nodes.
    Cheers1
    Abhi

  • Email notification if batch job fails

    Hi,
    My requirement is to send a notification to a user if the batch job fails.
    The batch job is a Z report program.
    Regards
    Suresh Kumar

    HI,
    Check this thread..
    When a Job in SM37 fails means a email should be send
    Regards,
    Omkar.

  • Email notification using Oracle Job

    Hi,
    I am trying to setup a email notification job using Oracle 11gR2. Per online documnetation I have done the following setup, but the email notification job is failing. If you guys have any ideas, please assist.
    Step 1:
    BEGIN
      DBMS_SCHEDULER.set_scheduler_attribute('email_server', 'oracle.kotaise.com:25');
      DBMS_SCHEDULER.set_scheduler_attribute('email_sender', '[email protected]');
    END;
    Step2:
    BEGIN
      DBMS_SCHEDULER.create_job (
        job_name        => 'email_notification_job',
        job_type        => 'PLSQL_BLOCK',
        job_action      => 'BEGIN NULL; END;',
        start_date      => SYSTIMESTAMP,
        repeat_interval => 'freq=minutely; bysecond=0',   
        enabled         => TRUE);
    END;
    Step 3:
    BEGIN
    DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
      job_name   =>  'email_notification_job',
      recipients =>  '[email protected]',
      sender     =>  '[email protected]',
      subject    =>  'Scheduler Job Notification-%job_owner%.%job_name%-%event_type%',
      body       =>   '%event_type% occurred at %event_timestamp%. %error_message%',
      events     =>  'JOB_FAILED, JOB_BROKEN, JOB_DISABLED, JOB_SCH_LIM_REACHED');
    END;
    Step 4:
    I have created the following  job that executes a package which executes a package "test_package.pdata". This package is not created yet, becuase I wanted to see whether the email notification is working or not. As expected the "TEST_JOB" is failed becuase of missing package. But the email notification job "'email_notification_job'", which runs every minute, failed to send an email notification.
    BEGIN
      SYS.DBMS_SCHEDULER.CREATE_JOB
           job_name        => 'test_job'
          ,start_date      => SYSTIMESTAMP
          ,repeat_interval => 'freq=minutely; bysecond=0'
          ,end_date        => NULL
          ,job_class       => 'DEFAULT_JOB_CLASS'
          ,job_type        => 'PLSQL_BLOCK'
          ,job_action      => 'BEGIN test_package.pdata; END;'
          ,comments        => NULL
          ,enabled         => TRUE
    end;
    I have queried the DBA_SCHEDULER_NOTIFICATIONS table, and I see that the email notification job did not started.
    JOB_NAME                                      RECIPIENT                     EVENT
    EMAIL_NOTIFICATION_JOB      [email protected]      JOB_FAILED
    EMAIL_NOTIFICATION_JOB      [email protected]      JOB_BROKEN
    EMAIL_NOTIFICATION_JOB      [email protected]      JOB_SCH_LIM_REACHED
    EMAIL_NOTIFICATION_JOB      [email protected]      JOB_DISABLED
    Thanks

    Hi,
    The DBA_SCHEDULER_NOTIFICATIONS show the notification settings, not the notifications that were sent. To see that, run the follwoing query:
    select queue,
           msg_state,
           enq_time,
           enq_user_id,
           deq_time,
           deq_user_id,
           t.user_data.event_type,
           t.user_data.object_owner,
           t.user_data.object_name,
           t.user_data.event_timestamp
      from sys.AQ$SCHEDULER$_EVENT_QTAB t;
    Does it show anything for your job?

  • Email notification for GRID job output

    Is it possible to get the job output in the email notification? I can currently get the job status but not the output.

    it may be bit tricky to include in your email notifications, but its possible to trace back to GRID JOB output.
    1. Get job JOB execution ID
    2. Get Latest output_id from job execution ID.
    3. You can do a select from
    SELECT output FROM MGMT_JOB_OUTPUT WHERE output_id=&OUTPUT_ID
    its explained in metalink note
    Note 300690.1 - Troubleshooting Script for Problematic Job Output in EM 10g Grid Control

  • ?my apple account used an email from a previous job that i can't access now

    My apple account was my ex work email I no longer have access to I thought i had changed it but when I try and update apps my user name still comes up with the old one and won;t let me chane it help please ?

    As Linc has said, those purchases are tied to your 'work' Apple ID.
    If you could proivde more information, maybe we can help.
    So you don't have access to the email address associated with the Apple ID, but do you have your AppleID  assword?  Are you unable to update the purchases in the App Store?  Did you forget the AppleID password at some point, and now you can not recover it?  If so, have you tried using the security questions to recover your account?
    Is this account tied to purchasing/billing for your former employeer, or is it a personal account that you happened to use your work email for?
    If you can access your account, have you tried the steps in this article?
    http://support.apple.com/kb/ht5621
    Apple ID is a little more flexible now in terms of renaming and using alternate email addresses, that is, if you can access the account.

  • Email Notification - Oracle Scheduled job failed

    Hi,
    Am on 12.1.3
    DB 11.1.0.7.0
    RHEL - 5.6
    I have created a job as below:
    BEGIN
    sys.dbms_scheduler.create_job(
    job_name => '"DMIG"."INSERT_LATEST"',
    job_type => 'STORED_PROCEDURE',
    job_action => '"APPS"."XXINSERT"',
    start_date => systimestamp at time zone 'America/Chicago',
    job_class => '"DEFAULT_JOB_CLASS"',
    auto_drop => FALSE,
    enabled => TRUE);
    END;
    It was sucessfull ..
    Now my requirement is , i want to get a mail if this job failed ..
    Thanks

    Duplicate post -- https://forums.oracle.com/forums/message.jspa?messageID=9844042

  • Send to Multiple email addresses using the job notification package

    I'm trying to send notifications to mulitple addresses, and have not been successful in creating the right syntax, I've tried:
    exec add_job_email_notification('J1','[email protected];[email protected]','JOB_FAILED');
    and other combinations. What is the trick to send to more the one address?

    Hi,
    As the documentation says, recipient_address may be a comma-separated list of e-mail addresses. So you should be using commas to separate you addresses e.g.
    '[email protected],[email protected]'
    Hope this helps,
    Ravi.

Maybe you are looking for