There is a script that runs tcpdump. How can I see tcpdump work in the console in real time, knowing its pid? The script itself is run via cron.
1 answer
Probably a Python script and it is written wrong
os.system(tcpdump -i eth0) that's how:
os.system("tcpdump -i eth0") Knowing pid when you run this script will not help you. In fact, you need to do this:
- Run crontab -e
- Find a row in the table that runs your script
- In this line, most likely, there is something like > / dev / null
- Replace with something like >> ~ / log_tcpdump.txt
- Run tail -f ~ / log_tcpdump.txt
- Wait for the script to run by time
- Watch his issue
The comments link to the recipe type:
tail -f / proc // fd / 1
Well ... It will give effect at once. And the next time you start your script, it will have a different PID and again - everything from the beginning.
- With the pid process everything is easy. If you are sure that there is only one process, then somewhere
tai -f /proc/$(pidof tcpdump)/fd/1. If there can be a lot of processes, then you need to do a cycle.for i in $(pidof tcpdump); do tailf /proc/$i/fd/1; donefor i in $(pidof tcpdump); do tailf /proc/$i/fd/1; done(yes, sometimestailfis better thantailf -f) - KoVadim - @KoVadim,
tailf- obsolete command, will be removed in 2017 - mymedia
|
os.system(tcpdump -i eth0). - kmz_61ps axit can be seen, but it is not clear how to output to the console - kmz_61