Shell and SQL

Source: Internet
Author: User
Tags file permissions




Cursor Movement Instructions
? Corresponding Direction key movement
H Move left one character K move up one line J Move down a line L move a character right

? Move by line unit
0 move to beginning $ move to end of line
NG moves to Nth line G to the last row
? Move by page unit
^ F Volume One screen ^ B roll up a screen
^ d lower half screen ^ u roll up half screen

--Catlina.out The last 100 rows of data in the log file
tail-100 catlina.out >> 20141214log.txt



--detection is useful
Head-10 20141214log.txt



--Under the Hwcsp6 folder, copy the file HWCSP6 package to Hwcsp6_201500807.tar

Tar-cvzf Hwcsp6_201500807.tar HWCSP6

Tar-xvzf Hwcsp6_201500807.tar

--from Linux to FTP
FTP address

The address to be saved by the CD

Bin--Switch to 2 binary

Put

--From FTP to Linux
FTP address

The address where the CD file resides

Bin--Switch to 2 binary


Get current folder under


--View the size of each file under the current folder
Linux:du-sh *
AIX:DU-SG *

--View Drive letter Usage
Df-h g for Units
Df-m m for units


Document Permissions Command
--Executable permissions, that is, x permissions
chmod +x script.sh

--Change the file group permissions to switch to the current file permissions under the user

CHGRP (change group abbreviation)-R (this parameter indicates that all files and folder groups under the changed folder are simultaneously changed) group file


--Change file user permissions

Chown (change owner abbreviation)-R (this parameter indicates that all files and folder groups under the Changed folder have been changed at the same time) owner file


--You can also use Chown to change permissions for users and groups

Chown-r user:grop File Change permissions for users and groups of files

TAR-CVF Csp_20151008_bak.tar CSP

--Transfer folders from local to Linux
Compress into zip format, put on FTP, get zip file by get
Re-use Unzip-o decompression
Unzip-o Csp.zip

--CP command
CP [parameter] files that need to be copied for the current file
R: For copying folders
P: Copy the past together with the original file attributes, not the default copy
I: If the copied file already exists, you will be asked if you need to continue copying it before overwriting.

Mv

Rm


--tar
Package all files under a folder (excluding the folder directory)
1. Enter this folder first
2. Execute in this folder: TAR-CZVF filename.tar.gz *
3, CD to need to unzip the folder under execution: TAR-XZVF filename.tar.gz




Cd



Ps-ef | grep java

---------------------------



Disk space cleanup
Disk space Cleanup (idealized hold 75%)
1.10.70.211.68 Etl/nij2sy5,
General Cleaning WORK01 and WORK02
1.work01:zjjavg09/work01/vgopbk/vgopbass/data/bass/mode
2.work02:zjjavg09/work02/vgopbk/vgopzj/bossop

2.10.70.211.76 Etl/sp7%ox (j
General cleaning WORK01 and WORK02, cleaning principles
Example: Work01:zjjavg03/work01/vgopbk/vgopckm/all_content/read
More space can be cleared as appropriate.
For example: Work02:zjjavg03/work02/vgopbk/vgopwap/data/data_bak can be cleaned
--View the size of each file under the current folder
Linux:du-sh *
AIX:DU-SG *

--View Drive letter Usage
Df-h g for Units
Df-m m for units




database table Space Cleanup steps:
The principle of deleting partitions is:
Day 2+1 Month Data retention
Special: Read retention 3+1 month, Tb_dw_wap_client_day keep last week
Month retention 6+1 Month data

Tb_dw_order_info_bass_579_d
Tb_dw_order_info_one_579_d
This type of table can retain less data for a minimum of 10 days



First step: Find out the space utilization
Select Tablespace_name "Table Space",
To_char (Round (bytes/1024, 2), ' 99990.00 ')
|| ' G ' is "real",
To_char (Round (free/1024, 2), ' 99990.00 ')
|| ' G ' "existing",
To_char (Round ((bytes-free)/1024, 2), ' 99990.00 ')
|| ' G ' "use",
To_char (Round (10000 * used/bytes)/100, ' 99990.00 ')
|| '% ' "ratio"
From (SELECT a.tablespace_name tablespace_name,
Floor (A.bytes/(1024x768)) BYTES,
Floor (B.free/(1024x768)) free,
Floor ((A.bytes-b.free)/(1024x768 * 1024x768)) used
From (SELECT tablespace_name tablespace_name,
Sum (BYTES) BYTES
From Dba_data_files
GROUP by Tablespace_name) A,
(SELECT tablespace_name Tablespace_name,
Sum (BYTES) free
From Dba_free_space
GROUP by Tablespace_name) B
WHERE a.tablespace_name = b.tablespace_name)
/*where tablespace_name like ' undo% '--This sentence specifies the tablespace name */
ORDER by Floor (10000 * used/bytes) DESC;


Step two: Find the big table that occupies space
SELECT * FROM (select T.segment_name, sum (t.bytes)/1024/1024/1024 as Tab_size
From User_segments t
GROUP BY T.segment_name
)
where tab_size>=50
ORDER BY tab_size Desc;

Step three: Delete a partition
----------------------------------------------------------
Select ' ALTER TABLE ' | | T.segment_name | | ' Drop Partition ' | |
T.partition_name | | ‘;‘
From User_segments t
where t.segment_name = Upper (' TB_MK_RING_DAY_JF ');


--Additional statements, IMPORTANT!!!
SELECT DISTINCT T.segment_name,
' ALTER TABLE ' | | T.segment_name | | ' Drop Partition ' | |
SUBSTR (T.partition_name, 1, 13) | | ‘;‘,
T1.tab_size,
SUBSTR (T.partition_name, 6, 14)
From User_segments T,
(Select Segment_name, tab_size
From (select T.segment_name,
SUM (t.bytes)/1024/1024/1024 as Tab_size
From User_segments t
Group BY T.segment_name)
where Tab_size >= 50
ORDER BY tab_size Desc) T1
where t.segment_name = T1.segment_name
and t.partition_name like '%part_201602% '
and T.partition_name <> ' part_201602 '
--and To_number (substr (T.partition_name, 6,)) < ' 20160206 '
and substr (T.partition_name, 6, +) < ' 20160211 '
and t.segment_name like ' tb_% '
--and t.partition_name = ' part_201508 '
--Group BY substr (T.partition_name, 1, 13)
ORDER BY t1.tab_size Desc


This article from "Sima" blog, declined reprint!

Shell and SQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.