<?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: Cron Issue: How to send a report on specific day? in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Cron-Issue-How-to-send-a-report-on-specific-day/m-p/380578#M6708</link>
    <description>&lt;P&gt;The Cron schedule is inclusive, so 1-7 will result in alerts being sent every day for that first week.  You can review sample crontab schedules at &lt;A href="https://crontab.guru/#0_23_*_*_2" target="_blank"&gt;crontab.guru&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;What I believe would work is using an Alert with a conditional trigger, then adding some logic to your search based on the current date/time of the results so that Splunk only meets the condition for sending an alert during the time window you want to trigger.&lt;/P&gt;

&lt;P&gt;For this example the search you're trying to send would include some kind of aggregate count, using "{base search} | eval count by myfield"&lt;/P&gt;

&lt;P&gt;Create a new saved search and set the cron schedule to run every tuesday:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;0 23 * * 2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...  set the search alert condition to "if custom condition is met" and add the criteria&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search count &amp;gt; 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then the following at the end of the saved search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    | eval da_wday=strftime(now(),"%w"), da_mday=strftime(now(),"%d")
    | eval count=case(da_mday&amp;lt;=7 AND da_wday==2,count,1==1,0)
    | fields - da_*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These additional search commands will zero out the "count" field unless the current day/time is in the first week (da_mday&amp;lt;=7) and the weekday is Tuesday (da_wday==2).  The search will run every Tuesday thanks to the Cron schedule in the saved search, but your custom alert condition will drop those since the alert condition isn't being met.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 01:15:41 GMT</pubDate>
    <dc:creator>wenthold</dc:creator>
    <dc:date>2020-09-30T01:15:41Z</dc:date>
    <item>
      <title>Cron Issue: How to send a report on specific day?</title>
      <link>https://community.splunk.com/t5/Alerting/Cron-Issue-How-to-send-a-report-on-specific-day/m-p/380577#M6707</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I'd like a report to be sent every first Tuesday of the month at 11:00 pm. Thinking logically, I should use this cron:  &lt;CODE&gt;0 23 1-7 * 2&lt;/CODE&gt;. But for some reason, I receive the report &lt;STRONG&gt;every&lt;/STRONG&gt; day during the first week of the month. &lt;BR /&gt;
Do you have an idea what am I doing wrong?&lt;/P&gt;

&lt;P&gt;Thanks for the help.&lt;BR /&gt;
Alex.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:18:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Cron-Issue-How-to-send-a-report-on-specific-day/m-p/380577#M6707</guid>
      <dc:creator>AlexeySh</dc:creator>
      <dc:date>2019-07-08T13:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Issue: How to send a report on specific day?</title>
      <link>https://community.splunk.com/t5/Alerting/Cron-Issue-How-to-send-a-report-on-specific-day/m-p/380578#M6708</link>
      <description>&lt;P&gt;The Cron schedule is inclusive, so 1-7 will result in alerts being sent every day for that first week.  You can review sample crontab schedules at &lt;A href="https://crontab.guru/#0_23_*_*_2" target="_blank"&gt;crontab.guru&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;What I believe would work is using an Alert with a conditional trigger, then adding some logic to your search based on the current date/time of the results so that Splunk only meets the condition for sending an alert during the time window you want to trigger.&lt;/P&gt;

&lt;P&gt;For this example the search you're trying to send would include some kind of aggregate count, using "{base search} | eval count by myfield"&lt;/P&gt;

&lt;P&gt;Create a new saved search and set the cron schedule to run every tuesday:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;0 23 * * 2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...  set the search alert condition to "if custom condition is met" and add the criteria&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search count &amp;gt; 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then the following at the end of the saved search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    | eval da_wday=strftime(now(),"%w"), da_mday=strftime(now(),"%d")
    | eval count=case(da_mday&amp;lt;=7 AND da_wday==2,count,1==1,0)
    | fields - da_*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These additional search commands will zero out the "count" field unless the current day/time is in the first week (da_mday&amp;lt;=7) and the weekday is Tuesday (da_wday==2).  The search will run every Tuesday thanks to the Cron schedule in the saved search, but your custom alert condition will drop those since the alert condition isn't being met.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:15:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Cron-Issue-How-to-send-a-report-on-specific-day/m-p/380578#M6708</guid>
      <dc:creator>wenthold</dc:creator>
      <dc:date>2020-09-30T01:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Issue: How to send a report on specific day?</title>
      <link>https://community.splunk.com/t5/Alerting/Cron-Issue-How-to-send-a-report-on-specific-day/m-p/380579#M6709</link>
      <description>&lt;P&gt;Hello @wenthold ,&lt;/P&gt;

&lt;P&gt;The solution is a bit more complicated that I thought &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; But it works perfectly fine.&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 06:58:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Cron-Issue-How-to-send-a-report-on-specific-day/m-p/380579#M6709</guid>
      <dc:creator>AlexeySh</dc:creator>
      <dc:date>2019-07-09T06:58:22Z</dc:date>
    </item>
  </channel>
</rss>

