Monitoring Splunk

How do I script Splunk commands in shell script to execute?

wkrupinsky
Explorer

I am writing a shell script which I will execute with a cron job to clean eventdata from files daily.  How do I script Splunk commands in shell script to execute?

 

Here is what I have:

cd /datadrive/opt/splunk/bin
./splunk clean eventdata -index audit
y
./splunk clean eventdata -index _internal
y
./splunk clean eventdata -index _introspection
y
./splunk clean eventdata -index _metrics
y
./splunk clean eventdata -index _telemetry
y
./splunk start

 

 

Any and all help would be greatly appreciated.

Labels (1)
Tags (1)
0 Karma

woodcock
Esteemed Legend

/datadrive/opt/splunk/bin/splunk stop
/datadrive/opt/splunk/bin/splunk clean eventdata -index audit --answer-yes

/datadrive/opt/splunk/bin/splunk clean eventdata -index _internal --answer-yes
/datadrive/opt/splunk/bin/splunk clean eventdata -index _introspection --answer-yes
/datadrive/opt/splunk/bin/splunk clean eventdata -index _metrics --answer-yes
/datadrive/opt/splunk/bin/splunk clean eventdata -index _telemetry --answer-yes
/datadrive/opt/splunk/bin/splunk start

0 Karma

wkrupinsky
Explorer

Thank you so much, I will try that

0 Karma

somesoni2
Revered Legend
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...