Need help with Crontab

Im setting up crontab to run a command at 0800
my current crontab entry is:

0 8 * * 1,2,3,4,5 tcpdump -s2000 -w'flowroute-%H%M.pcap' -G900 -W34

This should start the script at 800am monday through friday as i understand it.
I have tested this a couple times and it does not start as planned.
If this needs to be written into a script, I have tried that with this script

#!/bin/bash

#capture packets in 15 min segments and stops after 36 segments

tcpdump -s2000 -w'flowroute-%H%M.pcap' -G900 -W36

I have had no luck with both.

Any suggestions would be much appreciated.

tcpdump -s2000 -F filename -w'flowroute-%H%M.pcap' -G900 -W36

Don't you have to specify an output filename with -w?

be careful with the '%' in crontab:
'man crontab' yields:

     Only the first line (up to a `%' or end of line) of the com-
     mand  field  is  executed by the shell. Other lines are made
     available to the command as standard input. Any  blank  line
     or  line  beginning  with  a  `#'  is  a comment and will be
     ignored.
1 Like

I have the file name specified with -w command
-w'flowroute-%H%M.pcap

the "%H%M" is to capture the current time and add that to the file being created(this is my time stamp for the file)

With the % symbol in there, will this mess up the crontab in some way?
Any ideas for how to add the time to the file with out the % symbol?
Can I change the command to

tcpdump -s2000 -w'flowroute-/%H/%M.pcap' -G900 -W36

the backslash should escape the % in the command?

This is a forward slash - use the '\'

1 Like

Thank you so much vgersh99
I think that was what my trouble was :slight_smile:

Thank you for your information