How to add posts in pages

What is Add Post in Page?
I was struggling these many days as in WordPress whatever you add new post will default go to Home page only. So you my juniors and friends would like to see category related posts on pages was very difficult or they have to do search in my home page. You may wanted to created multiple pages based on the categories of posts or content you wish to post. With default wordpress settings you will not be able to do it.
How can we achieve it?
You have a plugin provided by wordpress or some nice authors. Go to your worpress admin dashboard and search for the plugin post in page which will bring you multiple plugins. You can choose anyone and follow the instructions to install and enable it.
How it works?
Very simple you have to do only two steps.
1. Install the plugin which you choose
2. Activate the plugin
3. Add a simple code in each page with your category name you wanted to displayed on that page. (Category will have clug name which is internally created by wordpress which is always small character of your category)
Sample:
I choosed “Posts for Page Plugin” and installed
Here is the code I added in my Oracle page as I have category Oracle with slug name as oracle.
posts-for-page cat_slug=’oracle’ hide_images=’false’ num=’5′ read_more=’
Read More »’ show_full_posts=’false’ use_wp_excerpt=’true’ strip_html=’true’ hide_post_content=’false’ show_meta=’true’

Now I am happy and able to see the posts based on categories
Note: Due to website security reason will delete the anonymous comments and users. If you are geniue user please email or leave a comment breifiely so that I can enable the comment and users. I know it is hard but please help to understand. Thanks in advance

How to resmgr cpu quantum wait

Issue:
When the DB Performance issue is reported, After checking found the server load is very low, CPU/IO 90+ percent free.
But many sessiones waiting on event “resmgr:cpu quantum”. From AWR report we can see “resmgr:cpu quantum” is the TOP one consuming 100% DB time

What/Why resmgr:cpu quantum :

“resmgr:cpu quantum” means a session is waiting in a resource queue, wait until resource manager assign CPU pieces to it.

The wait event resmgr:cpu quantum is a normal wait event used by the Oracle Resource Manager to control CPU distribution. The resmgr:cpu quantum only occurs when the resource manager is enabled and the resource manage is “throttling” CPU consumption.

This is due to DEFAULT_MAINTENANCE_PLAN. From 11g onwards every weekday window has a pre-defined Resource Plan called DEFAULT_MAINTENANCE_PLAN, which will become active once the related window opens. In 10gR2, DEFAULT_MAINTENANCE_PLAN is associated with WEEKNIGHT_WINDOW and WEEKEND_WINDOW.

You can confirm this using the below SQL
SQL> select name,value from v$parameter where name in (‘resource_manager_plan’,’resource_limit’)’

SQL> show parameter resource

SQL> select window_name,resource_plan,last_start_date,duration,enabled from dba_scheduler_windows;

Solution:

Note 392037.1 – Database ‘Hangs’. Sessions Wait for ‘resmgr:cpu quantum’
Note 1339803.1 Recommended Patches for CPU Resource Manager
Set the maintenance window to other time where CPU resource is available maximum
During peak time clear the resource_manager_plan to none
alter system set resource_manager_plan=” scope=both;

You can disable resource plan for specific days by following commands

execute dbms_scheduler.set_attribute(‘MONDAY_WINDOW’,’RESOURCE_PLAN’,”);
Note: The above command will disable resource plan for Monday only

How to purge logs in MYSQL

1.Login as root or admin privileged user

$ mysql -u root -p password

2. Purge the Logs with log number

test$ PURGE BINARY LOGS TO “mysql-bin.0900”
The above command will purge all logs before 0900 and keep the logs 900 and above

3. Purge the logs until specific date and time

test$ PURGE BINARY LOGS BEFORE “2009-09-02 22:00:00”;
This command will purge the logs before 2nd Sep 22:00 Hrs

How to scp from remote server multiple files

What is Secure Copy?

scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.

Basic syntax of SCP

scp source_file_name username@destination_host:destination_folder

“copy source_file_name” into “destination_folder” at “destination_host” using “username account”.

How to copy single file
$scp -p username@hostname:/u01/local/oracle/db_01/backup/<FileName> .

 

How to copy multiple files
To use wildcard on the remote host, we must delimit the wildcards with backslash (\)
example
$ scp -p username@hostname:/u01/local/oracle/db_01/backup/\*.dmp .

The above command will pass “*.dmp”

How to copy Entire folder

$ scp -p username@hostname:/u01/local/oracle/db_01/backup/\* .

Examples

1.1 Copy the file “foobar.txt” from a remote host to the local host

$ scp your_username@remotehost.edu:foobar.txt /some/local/directory

1.2 Copy the file “foobar.txt” from the local host to a remote host

$ scp foobar.txt your_username@remotehost.edu:/some/remote/directory

1.3 Copy the directory “foo” from the local host to a remote host’s directory “bar”

$ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar

1.4 Copy the file “foobar.txt” from remote host “rh1.edu” to remote host “rh2.edu”

$ scp your_username@rh1.edu:/some/remote/directory/foobar.txt \
your_username@rh2.edu:/some/remote/directory/

1.5 Copying the files “foo.txt” and “bar.txt” from the local host to your home directory on the remote host

$ scp foo.txt bar.txt your_username@remotehost.edu:~

1.6 Copy the file “foobar.txt” from the local host to a remote host using port 2264

$ scp -P 2264 foobar.txt your_username@remotehost.edu:/some/remote/directory
1.7 Copy multiple files from the remote host to your current directory on the local host

$ scp your_username@remotehost.edu:/some/remote/directory/\{a,b,c\} .

How to DBMS_SYSTEM Package

DBMS_SYSTEM package contains a number of procedures that can be useful. Oracle clearly state that these procedures are not supported so use at your own risk.

The package DBMS_SYSTEM is installed by running the script
$ORACLE_HOME/rdbms/admin/dbmsutil.sql
This script is internally called by
$ORACLE_HOME/rdbms/admin/catproc.sql
By default only the SYS user can execute procedures and functions in this package.

To allow other users to execute this package, run the following commands as SYS
GRANT EXECUTE ON dbms_system TO PUBLIC;
CREATE PUBLIC SYNONYM dbms_system FOR dbms_system;

Commonly used procedures or may required for DBA

ksdwrt
SET_SQL_TRACE_IN_SESSION
SET_EV
READ_EV

ksdwrt:

Used to write messages to the alertlog and/or trace files.

EXEC DBMS_System.ksdwrt(n, message);
EXEC DBMS_System.ksdwrt(2, ‘My Test Alertlog Message’);
Where the value of “n” indicates the destination.

1 – Write to trace file.
2 – Write to alertlog.
3 – Write to both.

Example:
To write a message to the trace file use
EXECUTE dbms_system.ksdwrt (1, ‘Output written to trace file’);
To write a message to the alert log use
EXECUTE dbms_system.ksdwrt (2, ‘Output written to alert log’);
To write a message to both the trace file and the alert log use
EXECUTE dbms_system.ksdwrt (3, ‘Output written to both trace file and alert log’);

SET_SQL_TRACE_IN_SESSION:

Used to set trace on or off in another users session.

EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid, serial#, true );
EXEC DBMS_SYSTEM.set_sql_trace_in_session(31, 97, true );

This is the equivalent to enabling event 10046 level 1.

For example to enable trace in a session with SID 9, use:
EXECUTE dbms_system.set_sql_trace_in_session (9, 29, true);
To disable trace in the same session use:
EXECUTE dbms_system.set_sql_trace_in_session (9, 29, false);
The SID and serial# for the session can be obtained from V$SESSION e.g.:
DECLARE
l_sid NUMBER;
l_serial NUMBER;
BEGIN
SELECT sid, serial#
INTO l_sid, l_serial
FROM v$session
WHERE username = ‘User1’;

dbms_system.set_sql_trace_in_session (l_sid, l_serial, TRUE);
END;
/

SET_EV:

Used to set trace on for a specific event.

EXEC DBMS_SYSTEM.set_ev(sid, serial#, event, level, name);
EXEC DBMS_SYSTEM.set_ev(31, 97, 10046, 4, ”);

Where level indicates the following levels of trace.

1 – Standard SQL_TRACE functionality.
4 – As level 1 plus tracing of bind variables.
8 – As level 1 plus wait events.
12 – As level 1 plus bind variables and wait events.

READ_EV:

Used to check if a specific event is currently being traced.

EXEC DBMS_SYSTEM.read_ev(event, output);

If output = 1 the event is being traced.

How to rotate log files

We can use simple linux commands to rotate logs. There are some tools also available to rotate the logs.
Method 1: Backup the log and make the log empty without stopping the service.
1.1 Backup the current Log

$ tail -100000 alert_UPGR.log > alert_UPGR.log.bak

$ ls -ltr alert_UPGR.log*
-rw-r—– 1 oracle oinstall 353665 Jul 4 00:41 alert_UPGR.log
-rw-r–r– 1 oracle oinstall 353665 Jul 4 00:52 alert_UPGR.log.bak
1.2 Compress the backed up Log

$ gzip alert_UPGR.log.bak
$ ls -ltr alert_UPGR.log*
-rw-r—– 1 oracle oinstall 353665 Jul 4 00:41 alert_UPGR.log
-rw-r–r– 1 oracle oinstall 33727 Jul 4 00:52 alert_UPGR.log.bak.gz
1.3 Empty the active log

$ >alert_UPGR.log

$ ls -ltr alert_UPGR.log*
-rw-r–r– 1 oracle oinstall 33727 Jul 4 00:52 alert_UPGR.log.bak.gz
-rw-r—– 1 oracle oinstall 0 Jul 4 00:53 alert_UPGR.log
1.4 Confirm the alert log is updated

SYS@UPGR:SQL> alter system switch logfile;

System altered.

SYS@UPGR:SQL> exit

$ ls -ltr alert_UPGR.log*
-rw-r–r– 1 oracle oinstall 33727 Jul 4 00:52 alert_UPGR.log.bak.gz
-rw-r—– 1 oracle oinstall 229 Jul 4 00:54 alert_UPGR.log
2. How to rotate Catalina.out log when it is more than 5M?.

2.1. Create this file

/etc/logrotate.d/tomcat

2.2. Copy the following contents into the above file

/var/log/tomcat/catalina.out { copytruncate daily rotate 7 compress missingok size 5M }

About the above configuration:
Make sure that the path /var/log/tomcat/catalina.out above is adjusted to point to your tomcat’s catalina.out
daily – rotates the catalina.out daily
rotate – keeps at most 7 log files
compress – compressesthe rotated files
size – rotates if the size of catalina.out is bigger than 5M

How to run shell script in background

We need sometime run the script in background

1. How to execute the script in Background
Let us say you have created script call test_bg.sh

Login to remote host with appropricate username and password

Syntax
$ nohup <scriptname> > <logname> &
Example:
$ nohup /home/oracle/mudhalvan/scripts/test_bg.sh > /home/oracle/mudhalvan/scripts/test_bg.log &

2. How to check any background jobs are running in this session
$ jobs

3. Test with example
oracle@localhost:~/mudhalvan/scripts$ cat test_bg.sh

find /. -name “test” -print
oracle@localhost:~/mudhalvan/scripts$ ls -ltr test_bg.sh
-rwxr-xr-x 1 oracle oinstall 29 May 27 19:43 test_bg.sh
oracle@localhost:~/mudhalvan/scripts$
oracle@localhost:~/mudhalvan/scripts$ nohup /home/oracle/mudhalvan/scripts/test_bg.sh > /home/oracle/mudhalvan/scripts/test_bg.log &
[1] 3865
oracle@localhost:~/mudhalvan/scripts$ jobs
[1]+ Running nohup /home/oracle/mudhalvan/scripts/test_bg.sh > /home/oracle/mudhalvan/scripts/test_bg.log &
oracle@localhost:~/mudhalvan/scripts$

4. Why we need to run the scripts in background

1. You may be connected remotely to the server and execute some script which need to be executed for more than few hours. Due to network issue or session security you remote session may disconnect which may cause your running script end at half way.

2. Long running script which will not take your one session of your remote client connection from your client machine.

5. Benifits of running a script in background

1. Disconnect or network disturbance on your remote client will not impact your script execution
2. You can use the current remote session for another process

1 5 6 7 8