find /path/to/search -name '*.jar' -exec sh -c 'jar -tf {} | grep -H --label {} MyClass.class' \;
Aiyo...!
Friday, May 10, 2024
Tuesday, February 11, 2020
Useful commands in docker container
Debian
apt-get update
apt-get install procps
apt-get install vim
apt-get update
apt-get install procps
apt-get install vim
Wednesday, March 27, 2019
Basic Cron Job in Linux
For listing all cron jonbs
#crontab -l
To edit cron jonbs
#crontab -e
Cron job command
0 0 * * * reg-clean.sh /usr/local/harbor > /dev/null 2>&1
Timing - set the minutes, hours, days, months, and weekday settings (more below).
Execute - excutable scirpt
Path to script - path to script
Output - (optional) you can write the output to a file or discard it - > /dev/null 2>&1 will discard
Timing
---------
Minutes - set the minutes, from 0-59
Hours - set the hour, from 0-24
Days - set the day, from 1-31
Months - set the month, from 1-12 (January - December)
Week - set the day of the week, from 0-6 (Sunday - Saturday)
Syntax Explanation
0 * * * * run once an hour (every hour at minute zero)
0 0 * * * run once a day (every day at midnight and minute zero)
0 0 1 * * run once a month (on the first day of every month at midnight and minute zero)
0 0 1 1 * run once a year (on the first day of the first month every year at midnight and minute zero)
#crontab -l
To edit cron jonbs
#crontab -e
Cron job command
0 0 * * * reg-clean.sh /usr/local/harbor > /dev/null 2>&1
Timing - set the minutes, hours, days, months, and weekday settings (more below).
Execute - excutable scirpt
Path to script - path to script
Output - (optional) you can write the output to a file or discard it - > /dev/null 2>&1 will discard
Timing
---------
Minutes - set the minutes, from 0-59
Hours - set the hour, from 0-24
Days - set the day, from 1-31
Months - set the month, from 1-12 (January - December)
Week - set the day of the week, from 0-6 (Sunday - Saturday)
Syntax Explanation
0 * * * * run once an hour (every hour at minute zero)
0 0 * * * run once a day (every day at midnight and minute zero)
0 0 1 * * run once a month (on the first day of every month at midnight and minute zero)
0 0 1 1 * run once a year (on the first day of the first month every year at midnight and minute zero)
Tuesday, January 30, 2018
List Table sizes
SELECT table_name AS "Tables", round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "live";
Wednesday, June 28, 2017
High load SQL in Oracle
select a.sql_id, a.ratio, a.executions
from
(
select sql_id, buffer_gets / executions ratio, executions
from v$sql
where executions > 10
order by 2 desc
) a
where rownum <= 10
/
select * from v$sql where sql_id='xxxxxxxx'
from
(
select sql_id, buffer_gets / executions ratio, executions
from v$sql
where executions > 10
order by 2 desc
) a
where rownum <= 10
/
select * from v$sql where sql_id='xxxxxxxx'
Tuesday, April 11, 2017
Java Heap Options of Productions
Make your Heap Explicit
-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:CMSInitiatingOccupancyFraction=60 -XX:+UseCMSInitiatingOccupancyOnly
-XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled
-Xms<heap size>[g|m|k] -Xmx<heap size>[g|m|k]
To avoid dynamic heap resizing and lags, which could be caused by this, we explicitely specify minimal and maximal heap size. Thus Java VM will spend time only once to commit on all the heap.
-XX:PermSize=<perm gen size>[g|m|k] -XX:MaxPermSize=<perm gen size>[g|m|k]
Logic for permanent generation is the same as for overall heap — predefine sizing to avoid costs of dynamic changes. Not applicable to Java >= 8.
-XX:MaxMetaspaceSize=<metaspace size>[g|m|k]
By default Metaspace in Java VM 8 is not limited, though for the sake of system stability it makes sense to limit it with some finite value.
-Xmn<young size>[g|m|k]
Explicitely define size of the young generation.
-XX:SurvivorRatio=<ratio>
Ratio which determines size of the survivour space relatively to eden size. Ratio can be calculated using following formula:
survivor ratio=young size/survivor size −2
Make GC Right
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
As response time is critical for server application concurrent collector feets best for Web applications. Unfortunatelly G1 is still not production ready, thus we have to use Concurrent Mark-Sweep collector.
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=<percent>
By default CMS GC uses set of heuristic rules to trigger garbage collection. This makes GC less predictable and usually tends to delay collection until old generation is almost occupied. Initiating it in advance allows to complete collection before old generation is full and thus avoid Full GC (i.e. stop-the-world pause). -XX:+UseCMSInitiatingOccupancyOnly prevent usage of GC heuristics. -XX:CMSInitiatingOccupancyFraction informs Java VM when CMS should be triggered. Basically, it allows to create a buffer in heap, which can be filled with data, while CMS is working. Thus percent should be back calculated from the speed in which memory is consumed in old generation during production load. Such percent should be chosen carefully, if it will be small — CMS will work to often, if it will be to big — CMS will be triggered too late and concurrent mode failure may occur. Usually -XX:CMSInitiatingOccupancyFraction should be at the level 70, which mean that application should utilize less that 70% of old generation.
-XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark
Instructs garbage collector to collect young generation before doing Full GC or CMS remark phase and as a result improvde their performance due to absence of need to check references between young generation and tenured.
GC Logging
-XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -Xloggc:"<path to log>"
These options make Java to log garbage collector activities into specified file. All records will be prepended with human readable date and time. Meanwhile you should avoid using -XX:+PrintGCTimeStamps as it will prepend record with useless timestamp since Java application start.
Generate log can be later analysed with GCViewer.
-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M
GC log files rotation makes analysis of garbage collection problems easier, also it guaranties that disk is protected from space overconsumption.
http://blog.sokolenko.me/2014/11/javavm-options-production.html
Wednesday, February 1, 2017
Oracle Currently Running SQLs
select sesion.sid,
sesion.username,
optimizer_mode,
hash_value,
address,
cpu_time,
elapsed_time,
sql_text
from gv$sqlarea sqlarea, gv$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null
and sesion.inst_id=1
sesion.username,
optimizer_mode,
hash_value,
address,
cpu_time,
elapsed_time,
sql_text
from gv$sqlarea sqlarea, gv$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null
and sesion.inst_id=1
Subscribe to:
Posts (Atom)