Im tired of trying to find a answer to this. I got 2 scripts that are in crontab -e command.
START_TCPDUMP.sh
#!/bin/bash
tcpdump -i any port 3306 -s 65535 -x -nn -q -tttt> /etc/openvpn/logs/tcpdump_3306_"$(date +"%Y_%m_%d_%I_%M_%p")".out
STOP_TCPDUMP.sh
PID=$(/usr/bin/ps -ef | grep tcpdump | grep -v grep | grep -v ".sh" | awk '{print $2}')
/usr/bin/kill -9 $PID
CRONTAB -E
*/1 * * * * /etc/openvpn/script/STOP_TCPDUMP.sh
*/1 * * * * /etc/openvpn/script/START_TCPDUMP.sh
I already tryied to change and put start at first line but its all the same.
My output on directory every 1 min its:
/etc/openvpn/logs/tcpdump_3306_2020_01_29_12_22_PM.out (empty: 0kb)
The problem is that files are empty I already tried so much things and its always empty. How can I figure this out?
Also If I run: ps -e | grep tcpdump I get 0 results. But If I run: grep | tcpdump I saw the command running and showing me all the tracked packages..
I just want it to run like 3h and then stop, save the file and then start a new one.
The once per minute schedule is merely for debugging.