LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-28-2011, 07:49 AM   #1
suprstar
Member
 
Registered: Aug 2010
Location: Atlanta
Distribution: ubuntu, debian
Posts: 142
Blog Entries: 2

Rep: Reputation: 21
suppress all output


Here is a little script that logs all http traffic, works great. My problem is that this is in an hourly cronjob, and the 'kill' line is producing this output:

/root/cronjobs/cap.sh: line 6: 1938 Killed /usr/sbin/tcpdump -nvi eth1 -s 0 src port 80 -X >&$filename

I am getting an email every hour because of this. I tried putting > /dev/null at the end but it still gives me this output. When I run the script on the command line, I do NOT get any output at all, so it's kinda difficult to troubleshoot.. How can I suppress this output?

Code:
#!/bin/bash
filename=/tmp/cap.`date +%Y-%m-%d.%H%M`.txt
/usr/sbin/tcpdump -nvi eth1 -s 0 dst port 80  -X &> $filename &
cpid=$!
sleep 3600
kill -9 $cpid
 
Old 11-28-2011, 07:58 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,398

Rep: Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965
kill -9 $cpid 2>&1 > /dev/null
 
Old 12-05-2011, 09:47 AM   #3
suprstar
Member
 
Registered: Aug 2010
Location: Atlanta
Distribution: ubuntu, debian
Posts: 142
Blog Entries: 2

Original Poster
Rep: Reputation: 21
Thanks, I have a test script working correctly now. But the production script still doesnt, and I cant see the difference between the 2. The working script runs in cron on the same server every minute. It's definitely creating the 10 second cap file, I'd never know except the file cap.txt is always within 1 minute of system time. The bit at the end of the non-working script just sends the hourly cap file to another server for parsing and databasing, and cleans up after itself.

Test script works, successfully suppresses output (email to root):
Code:
#!/bin/bash
filename=/root/cap.txt
/usr/sbin/tcpdump -nvi eth1 -s 0 src port 1812 or dst port 1812 or dst port 1813 or dst port 1813 -X &> $filename &
cpid=$!
sleep 10
kill -9 $cpid 2>&1 > /dev/null
Production script still sends email to root:
Code:
#!/bin/bash
filename=/home/msbackup/r3.`date +%Y-%m-%d.%H%M`.txt
/usr/sbin/tcpdump -nvi eth1 -s 0 src port 1812 or dst port 1812 or dst port 1813 or dst port 1813 -X &> $filename &
cpid=$!
sleep 3620
kill -9 $cpid 2>&1 > /dev/null
su - msbackup -c "/home/msbackup/sendr3cap $filename"
rm -f $filename
email:
/root/r3cap/go: line 6: 32262 Killed /usr/sbin/tcpdump -nvi eth1 -s 0 src port 1812 or dst port 1812 or dst port 1813 or dst port 1813 -X >&$filename
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] suppress a particular warning yousafsajjad Programming 7 10-09-2011 02:00 AM
how to suppress some of ls's output? BrianK Linux - General 2 03-03-2006 03:16 PM
How to suppress output from reiserfs mount jwezel Linux - Software 5 09-27-2005 01:24 AM
Suppress Iptables' Output mrsolo Linux - Software 1 05-05-2003 08:45 PM
how to suppress colors frankie_g Linux - Newbie 6 05-15-2002 10:52 AM


All times are GMT -5. The time now is 11:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration