Alerting

Cron Expression for Scheduled Alerts

richard8
Engager

Hi All,

Trying to configure an alert that runs on the first Sunday only of every month, specifically at 9:30am.

I put this as the cron expression: 30 9 1-7 * 0

If I'm reading the documentation correctly, that should be it. However, the alert appears to be running every Sunday of every month instead of just the first Sunday of every month.

Am I doing something wrong? Can't figure it out....

Thanks!

Labels (2)
0 Karma
1 Solution

livehybrid
SplunkTrust
SplunkTrust

Its not possible within Splunk to have a crontab for the first Sunday of the month, however.. you might be able to run it every day for first 7 days of the month (`30 9 1-7 * *`) and add the following to your search:

| where strftime(now(),"%a")=="Sun"

This will stop the search from continuing if it isnt Sunday...

Does this help?

Please let me know how you get on and consider accepting this answer or adding karma this answer if it has helped.
Regards

Will

View solution in original post

kiran_panchavat
Champion

@richard8 

This is your cron expression. Your cron expression 30 9 1-7 * 0 is not quite right because it triggers on any date (1-7) that is a Sunday (0), meaning it runs on every Sunday within the first seven days of the month. However, if the 1st of the month is not a Sunday, it will still run on other Sundays within that range.

kiran_panchavat_0-1739337061495.png

 

Did this help? If yes, please consider giving kudos, marking it as the solution, or commenting for clarification — your feedback keeps the community going!
0 Karma

livehybrid
SplunkTrust
SplunkTrust

Its not possible within Splunk to have a crontab for the first Sunday of the month, however.. you might be able to run it every day for first 7 days of the month (`30 9 1-7 * *`) and add the following to your search:

| where strftime(now(),"%a")=="Sun"

This will stop the search from continuing if it isnt Sunday...

Does this help?

Please let me know how you get on and consider accepting this answer or adding karma this answer if it has helped.
Regards

Will

richard8
Engager

This worked well 🙂

Thanks!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...