Sponsored Content
Top Forums Shell Programming and Scripting How can i make my cron/script to generate a log filename with timestamp in it ? Post 302931662 by Corona688 on Wednesday 14th of January 2015 12:19:10 PM
Old 01-14-2015
Code:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /tmp/test/mytestscpt.sh > /tmp/test/logs/crnlog-$(date +%Y-%m-%d-%H-%M-%S).log

Dates in YYYY-MM-DD-HH-MM-SS order sort, compare, and match easily.
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to add a timestamp to a filename?

whats going on guys. below is a script i made and am just curious if there is a "time stamp" command. so i can set the timestamp in a filename. #! /bin/ksh # # This scripts takes a list of files in the INDIR variable and compairs it to a list of files that are open in the same directory.... (2 Replies)
Discussion started by: Optimus_P
2 Replies

2. Shell Programming and Scripting

add timestamp to filename

Does anyone know how to add a timestamp to a file's name extension in a shell script? Please help.. (3 Replies)
Discussion started by: walterja
3 Replies

3. Shell Programming and Scripting

Modify script to generate a log file

I've seen several examples of scripts in thise forum about having a script generate a log file. I have a script that is run from cron and that monitors a file system for a specfic filename(s) and then performs some actions on them. Normally I call this script from another script (which the one... (2 Replies)
Discussion started by: heprox
2 Replies

4. Shell Programming and Scripting

Timestamp in the filename

Hi i want to replace the previous time stamp with the current timsatp at the start of the file like 20090710_113354_FT0710a.txt this one to 20091111__113354_FT0710a.txt thanks in advance (3 Replies)
Discussion started by: Reddy482
3 Replies

5. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

6. Programming

Generate a binary file using make

Hi, i am trying to create a makefile for my C++ program. when i say "make" it should generate the binary file. and when i say make clean, it should delete all the bins and libs. can u please help me out. (5 Replies)
Discussion started by: sunshine23
5 Replies

7. Shell Programming and Scripting

How to extract timestamp from the filename?

Hi., My file name is of the format: name_abc_20100531_142528.txt where., my timestamp is of the format: yyyymmdd_hhmmss How to extract the date strring and time string into seperate variables in the shell script, after reading the file as the input? I want to get the variables... (9 Replies)
Discussion started by: av_vinay
9 Replies

8. Shell Programming and Scripting

Get filename with size and timestamp

Hi, Below is a directory containing links new2,list,new1. I need to get the size and timestamp for them. How do i get these details. Please help lrwxrwxrwx 1 xxx abc 11 Nov 24 17:34 new2 -> ./org1/new2 lrwxrwxrwx 1 xxx abc 11 Nov 24 17:34 list -> ./org2/list lrwxrwxrwx 1 xxx abc 10... (2 Replies)
Discussion started by: pradebban
2 Replies

9. Shell Programming and Scripting

Filename timestamp

Hi Gurus, I have different files with different timestamp and different base file name, I have to group those files based on basename and provide a unique file name for similar file names. My Directory has following files. abc_filename_20130623:00:09:00.txt... (1 Reply)
Discussion started by: user_linux
1 Replies

10. Shell Programming and Scripting

How to sort the timestamp in the filename in shell script?

originally the shellscript #ln_file_name=`echo $ld_interface_date"_"${8}".csv"` #ln_file_name=`echo 201202011527_HL_HLTM1_B04A.csv` ln_file_name="*"`echo ${7}".csv"` get_file_list_1=$log_path"tm1_file_list.gfl1" cd ${source_path} echo "Try to find any file exist in the... (10 Replies)
Discussion started by: feilhk
10 Replies
DNSHISTORY(1)							   User Commands						     DNSHISTORY(1)

NAME
dnshistory - processes various log file formats doing dns IP Address lookups. Store these pairs in a database for later retrieval. SYNOPSIS
dnshistory [OPTION]... [--file=FILE] COPYRIGHT
dnshistory is Copyright (C) 2004, 2005, 2006, 2007 Stephen McInerney DESCRIPTION
dnshistory currently processes Apache CLF and Combined logs, Squid access logs, FTP xferlog files and iptables based logs. The log format is auto-detected. dnshistory has five modes of operation: o Do Lookups. The default mode. Given a web log file, dnshistory will perform DNS reverse lookups on each unique IP Address and store the results in a history database. o Do Translations. Given a raw web log file, dnshistory will make use of a previously created history database and send to STDOUT the same web log but with addresses replaced by the Fully Qualified Domain Name as previously looked up. o Do Recombining. Given two web log files, one raw and one previously translated (eg. by using dnstran): Create a history database from the values in these separate log files. o Do Dump. Dump a given history database to STDOUT. o Do Import. Import a previously dumped history database from a given file. o Show History. Given one or more IP Addresses on the command line, show the history of those addresses. The lookups make use of threads for maximum speed, and use the standard resolution libraries on a system. Thus hosts files, NIS, LDAP and other name resolution methods should work transparently. It is strongly recommended that for massive lookups a DNS server is "nearby". Preferably not a forwarding server. dnshistory can read .gz files. STDIN is assumed to not be gz encoded. OPTIONS
-L --dolookups The default mode. Given a log file, either via STDIN or via '-f', do the lookups and store the results. -T --dotranslate Given a log file, either via STDIN or via '-f', lookup each IP Address from the history database; replace the IP Address with the FQDN and send the newly updated log line to STDOUT. -R --dorecombine=FILE Given a previously translated file (eg. via dnstran) via this option for the names, do the lookups for a file given via STDIN or '-f' and store the results. This file can be gz encoded. The date/time of each stored entry is taken as being the actual time for the lookup stored in the recombine log file. This is proba- bly incorrect, but "Good Enough". -D --dodump Dump the history database to STDOUT. -I --doimport=FILE Given a previously dumped database, import that into a new database. Will fail and exit if the chosen database already exists. -S --showhistory Given one or more IP Addresses show their history. Address are the last item(s) on the command line. Addresses with no as yet dis- covered FQDN will display 'NONAME'. The Date/Time displayed is formatted as YYYY-MM-DD:hh:mm:ss, vs the 'seconds since epoch' for "--dodump" --logtype=LOGTYPE By default dnshistory will attempt to autodetect what type of logfile is being processed. By using this option, the autodetection is overridden. The choices are: auto, clf or www, squid, ftp or iptables. -c --cache=SIZE Set the size of the memory cache to use. Value is in Mb. Default is 20Mb. -d --database=FILE Change the default database file to use to store stateful data. -f --file=FILE Web Log File to process. This file can be gz encoded. Will use STDIN if not set -h --help Help screen. Very brief. -l --maxlookups=NUMBER The maximum number of lookups to attempt. The default is 1. This has not shown to be at all useful in testing... -m --maxthreads=NUMBER How many name lookup threads to spawn off. The default is 100. Setting this too high can do evil things to bandwidth and the CPU usage of any queried DNS server(s). If doing lots of DNS queries, setting this too high can have a very negative impact on the ability to successfully resolve anything. -t --timeout=VALUE The time in seconds before a stored DNS value is deemed "old". The default is 7 days. -v --verbose Verboseness of a run. More v's will increase the level of verbosity, up to a maximum of 5. All of the higher levels are only of value for debugging purposes. -V --version Display the version information and exit -w --wait Delay time between query retries within a single run RESULTS
At verbose level 1 (-v) some success/failure counters will be displayed. As well as any problematic log lines to STDERR. At verbose level 2 (-vv) lines that may not match up (eg. Due to dnstran modifying referrers or URL's) will be sent to STDERR. EXAMPLES
A typical run, using a database in /tmp/ (/tmp/c.db), and a log file in the current directory (test.log). First, do the lookups: dnshistory -d /tmp/c.db -f test.log Then the translation run for input into, for example, a web log analyser: dnshistory -T -d /tmp/c.db -f test.log | webalizer .... Do three attempts on failed queries, with a 2 second delay between retries: dnshistory -l 3 -w 2 -d /tmp/c.db -f test.log Lookup and Display the history of three IP Addresses: 127.0.0.1,192.168.1.254,10.10.10.10 dnshistory -S -d /tmp/c.db 127.0.0.1 192.168.1.254 10.10.10.10 Import a previously dumped database via dnsdb.dump dnshistory -I dnsdb.dump -d /tmp/d.db FILES
/var/lib/dnshistory/dnshistory.db The default history database file. BUGS
o Ignores IP Addresses located in the URL and Referrer fields. AUTHOR
Stephen McInerney <spm@stedee.id.au> Linux JANUARY 2007 DNSHISTORY(1)
All times are GMT -4. The time now is 09:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy