Sponsored Content
Top Forums Shell Programming and Scripting Shell script for log archiving Post 302467277 by Chubler_XL on Thursday 28th of October 2010 08:59:07 PM
Old 10-28-2010
Here is a script for a)

Code:
ls /jvm[1-5]/logs/*server.log* | grep -v .gz | while read file
do
   gzip $file
done

How about this bash / ksh script for b)

Code:
host=$(hostname)
host=${host%.*}
MTH=$(date +%m-%Y)
# ensure at lease 1 file exists
[ "$(echo /jvm[1-5]/logs/*.gz)" = '/jvm[1-5]/logs/*.gz' ] && exit
for file in /jvm[1-5]/logs/*.gz
do
    topdir=${file#/}
    topdir=${topdir%%/*}
    base=$(basename $file)
    mkdir -p /logfile/project/$MTH
    mv $file /logfile/project/$MTH/${host}-${topdir}-${base}
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

creating an archiving script

Hi all. New to unix and need a little help. I am trying to create a script to archive files or directories in to a tarball. I've played a little with scripts but dont understand how to do options. What i want to be able to do is give the command any number of inputs and an output. ex.... (2 Replies)
Discussion started by: jinxe
2 Replies

2. Shell Programming and Scripting

creating a simple archiving script

Im trying to create a script to archive specified directories into a specified tarball backup file. This is what i want the input to look like ex. save -i '/bin/b*' -i '/bin/ls' -o backup this is what i have #!/bin/bash #save - backup file script unset myInput unset myOutput while... (3 Replies)
Discussion started by: lensmen
3 Replies

3. Shell Programming and Scripting

Shell script to parsing log

Hi I Have log like this : 0 234: { 3 2: 04 EE 7 14: '20081114081' 23 1: 00 79 10: '38809' 91 15: '528111510010159' 143 29: 'Streaming/downloading service' 174 3: 'MTV' 179 43: 'rtsp://172.28/MTV2GO-Loop.sdp' 224 1: 05 ... (10 Replies)
Discussion started by: justbow
10 Replies

4. Shell Programming and Scripting

Script for Archiving data folderwise

Hi, I want to archive more than 15 days old files from /var/spool/ directory which contains 67 folders. I have done a script for a single folder which is as follows : cd /data1/ctron80/var/spool/bmaprt/ find . -mtime +15 | awk '{print "mv " $1 " /back/spool/bmaprt"}' | sh cd /back/spool/... (1 Reply)
Discussion started by: tuxian
1 Replies

5. Shell Programming and Scripting

What extra Parameters I can use for archiving log files

Hello All, I have developed a script which takes following parameter from the input file to archive log files 1)Input Path 2)File pattern(*.csv) 3)Number of days(+1) Following is the algorithm of my script Read the input file go to that path and search for particular n days older... (3 Replies)
Discussion started by: mitsyjohn
3 Replies

6. Shell Programming and Scripting

Archiving a log file on monthly basis

OS : RedHat Linux 6.2 Shell : Bash Our application write messages, warnings,..etc to the following log file . /app/cms/diagnostics/logs/cms_messages.log This file has become huge now. I want this file to be archived on monthly basis using a small shell script. ie. On the 1st day of... (1 Reply)
Discussion started by: omega3
1 Replies

7. Shell Programming and Scripting

Archiving or removing few data from log file in real time

Hi, I have a log file that gets updated every second. Currently the size has grown to 20+ GB. I need to have a command/script, that will try to get the actual size of the file and will remove 50% of the data that are in the log file. I don't mind removing the data as the size has grown to huge... (8 Replies)
Discussion started by: Souvik Patra
8 Replies

8. Shell Programming and Scripting

Archiving files using shell script

Dear Team, I am looking for transferring files to and from the local and remote servers using SFTP commands. Currently the script is using the mget and mput commands to do the copying of the files. While I am trying to move the files from local to remote server, I would also like to archive... (21 Replies)
Discussion started by: Rads
21 Replies

9. Shell Programming and Scripting

Shell Script function to use script name for log file output

Hi Team - I"m very new to Shell Scripting so I have a rather novice question. My forte is Windows Batch Scripting so I was just wondering what the Shell Script equivalent is to the DOS command %~n? %~n is a DOS variable that dispayed the script name. For instance (in DOS): REM... (11 Replies)
Discussion started by: SIMMS7400
11 Replies

10. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies
asadmin-create-jvm-options(1AS) 				   User Commands				   asadmin-create-jvm-options(1AS)

NAME
asadmin-create-jvm-options, create-jvm-options - creates the JVM options from the Java configuration or profiler elements SYNOPSIS
create-jvm-options --user admin_user [--password admin_password][--host localhost] [--port 4848] [--secure|-s] [--passwordfile filename] [--terse=false] [--echo=false] [--interactive=true] [--profiler=false ](jvm_option_name=jvm_option_value)[:jvm_option_name=jvm_option_value]* Creates the JVM options in the Java configuration or Profiler elements of the domain.xml file. You can enter more than one JVM option sepa- rated by a colon (:) . If the JVM option starts with a dash (-) then use two dashes (--) before the operand to distinguish that JVM option is an operand and not an option. JVM options are used to record the settings needed to get a particular profiler going. You must restart the server for the newly created JVM options to take affect. Use the start-domain command to restart the server domain. OPTIONS
--user authorized domain application server administrative username. --password password to administer the domain application server. --host machine name where the domain application server is running. --port port number of the domain application server listening for administration requests. --secure if true, uses SSL/TLS to communicate with the domain application server. --passwordfile file containing the domain application server password. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. Default is false. --echo setting to true will echo the command line statement on the standard output. Default is false. --interactive if set to true (default), only the required password options are prompted. --profiler indicates if the JVM options is for the profiler. Profiler must exist for this option to be true. OPERANDS
jvm_option_name=jvm_optithevleft side of the equal sign (=) is the JVM option name. The right side of the equal sign (=) is the jvm_option_value. Additionally, you can use ":" as a delimiter for more than one jvm-option. If the jvm-option contains a ":", use the escape character to offset the ":" delimiter. Example 1: Using create-jvm-options asadmin> create-jvm-options --user admin --password adminadmin --host localhost --port 4848 --profiler=false --DDebug=true:"-Xmx256m":" -Dcom.sun.aas.imqBin"="/export/as7se/imq/bin" Command create-jvm-options executed successfully Where the JVM options are created. The double dash (--) is used between --profiler options and the operand because - indicated the end of the options and the following text is the operand. The double dash (--) is necessary here since there are single dashes (i.e., --DDebug) in the operand. To distinguish between the options and the operand, the double dash (--) is used. EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-delete-jvm-options(1AS) J2EE 1.4 SDK March 2004 asadmin-create-jvm-options(1AS)
All times are GMT -4. The time now is 04:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy