1823114 Members
3261 Online
109646 Solutions
New Discussion юеВ

Re: IP trace in crontab

 
SOLVED
Go to solution
Kadavan
Occasional Advisor

IP trace in crontab

Hi All

I need a to create a script that needs to run IPTRACE at 3:00 AM every day and stops at 9:00 AM every day

Command to be excecuted
iptrace -a -i en0 -s 192.168.20.5 -b -d 165.130.149.28 -p 9081 /opt/isv/WAS51/trace/webtrace280311.out
3 REPLIES 3
Marco A.
Esteemed Contributor
Solution

Re: IP trace in crontab

Hi,

I have a fast solution for you.

Your crontab will look like this:
0 3 * * * /tmp/your_script.sh

your_script.sh
#!/bin/sh
iptrace -a -i en0 -s 192.168.20.5 -b -d 165.130.149.28 -p 9081 /opt/isv/WAS51/trace/webtrace280311.out

Another line at cron
0 9 * * * /tmp/kill_your_script.sh

kill_your_script.sh
#!/bin/sh
ps -ef | grep -i your_script.sh | awk '{printf $2}' | xargs kill -9



It should work like that.

Marco,
Just unplug and plug in again ....
Dennis Handly
Acclaimed Contributor

Re: IP trace in crontab

00 03 * * * iptrace -a -i en0 -s 192.168.20.5 -b -d 165.130.149.28 -p 9081 /opt/isv/WAS51/trace/webtrace280311.out

This starts it at 0300. To stop it you would need to start another script at 0900 to find and kill it.

Also, you may want to write a script for the iptrace case, so you can record the PID, sleep for 6 hours and have that script kill iptrace:
iptrace -a -i en0 -s 192.168.20.5 -b -d 165.130.149.28 -p 9081 /opt/isv/WAS51/trace/webtrace280311.out &
PID=$!
sleep $(( 6 * 60 * 60 )) # sleep 6 hours
kill $PID
Kadavan
Occasional Advisor

Re: IP trace in crontab

Thanks for the valuable support ..I could find the solution from this thred