Using date as part of logfile name
I would like to write a shell script but am quite new to it. Not sure how to start.
Using the shell script, I hope to run tcpdump and save / log tcpdump's output into a file that the current date is included in the file name. Eg today is 060504. When I run tcpdump via the shell script, I would like it to direct its output to a file say tcpdumplog060504 - something like that. Then say for the next day, if I run it again, it will log to tcpdumplog070504. So on and so forth. How can I do this? Hope someone can help me out and provide some guidance. I am planning to use cron to run the shell script. Thanks a million. James |
Redirect it to something like "tcpdumplog`date +%d%m%y`"
Code:
tcpdump -options > "/var/log/tcpdumplog`date +%d%m%y`" |
I'd suggest yyyy-mm-dd-tcpdump to have a logical
order by timestamps ;) |
using yyyy-mm-dd-tcpdump ?
Thanks for the help. Really appreciate it.
Tinkster, how can I code using yyyy-mm-dd-tcpdump? I am new at this so hope you can provide an example. Thanks again. James |
Almost the same as demonane's...
tcpdump -options > "/var/log/`date +%Y%m%d`-tcpdumplog" Cheers, Tink |
Log to text file
I would like the log files to have the txt extension so I can view it.
How would I go about this? Thanks James |
Code:
tcpdump -options > "/var/log/`date +%Y%m%d`-tcpdumplog.txt" Cheers, Tink |
Thanks
THanks for all the help.
Appreciate it. James |
All times are GMT -5. The time now is 07:14 PM. |