????Linux bash shell??????????£???????????????????????????????????б???????????????????????SQL??????????????????е?????????Щ????????????????bash????????????????????????ɡ??????????????Linux??????????л???????????????????????????ι????

????1??????????????

?????????????????????????????????????ж????pid?????????????????????

???????????????????????????????????????shell??????shell???????

?????????????????塣

??????????????????????????????????????????????????

?????????????????????????е????????????????????????[ctrl]+c?????????????bg??fg????????????

????2??????????????????

????a??command &  ??????????????????
????b??[ctrl]+z   ?????????л??????
????c??jobs       ??????????
????d??fg %n      ?ú?????е????n?л???????
????d??bg %n      ??????????n????????
????e??kill %n    ???????????n

????"n" ?jobs?????????job???????????id??

????????job????????????job?????????????????1???????

????job ???????????[n]????????????? "+" ????? "-" ????????????????

????"+" ???????????job??"-" ?????????????????е?Job?????"+" ???? "-" ????????????????????????????仯??

???????jobs???????????????????????????????????????

????3???????????????

a????????????????(???? & ????)
robin@SZDB:/tmp> tar -czvf temp.tar.gz tempSYBO2SZ.dbf &
[1] 12500
robin@SZDB:/tmp> tempSYBO2SZ.dbf

robin@SZDB:/tmp>              #???????????????????????????????????μ????
[1]+  Done                    tar -czvf temp.tar.gz tempSYBO2SZ.dbf

robin@SZDB:/tmp> ls -hltr temp*
-rwxr-xr-x 1 robin oinstall 490M 2013-05-02 17:48 tempSYBO2SZ.dbf
-rw-r--r-- 1 robin oinstall 174M 2013-05-02 17:50 temp.tar.gz

b??????????У????????????(???[ctrl]+z)
robin@SZDB:/tmp> tar -czvf temp2.tar.gz tempSYBO2SZ.dbf
tempSYBO2SZ.dbf

[1]+  Stopped                 tar -czvf temp2.tar.gz tempSYBO2SZ.dbf
robin@SZDB:/tmp> jobs
[1]+  Stopped                 tar -czvf temp2.tar.gz tempSYBO2SZ.dbf

#????????????????????????????????[ctrl]+z????????????????
robin@SZDB:/tmp> find /u02 -type f -size +100000k 
robin@SZDB:/tmp> find / -type f -size +100000k

#??β??????jobs???jobs?????????????3??????stopp????job
robin@SZDB:/tmp> jobs
[1]   Stopped                 tar -czvf temp2.tar.gz tempSYBO2SZ.dbf
[2]-  Stopped                 find / -type f -size +100000k
[3]+  Stopped                 find /u02 -type f -size +100000k

robin@SZDB:/tmp> jobs -l    #???-l?????????shell?????е????????????job number??????pid
[1]  32682 Stopped                 tar -czvf temp2.tar.gz tempSYBO2SZ.dbf
[2]- 32687 Stopped                 find /u02 -type f -size +100000k
[3]+ 32707 Stopped                 find / -type f -size +100000k

#???????pid??????????????????
robin@SZDB:/tmp> ps -ef | grep 32707 | grep -v grep
robin    32707 32095  0 09:48 pts/1    00:00:00 find / -type f -size +100000
robin@SZDB:/tmp> tty      #???????????pts/1
/dev/pts/1

#????????????
robin@SZDB:~> tty
/dev/pts/3
robin@SZDB:~> jobs                                 #??????????jobs???????κη???
robin@SZDB:~> ps -ef | grep 32707 | grep -v grep   #???????????id???????????????
robin    32707 32095  0 09:48 pts/1    00:00:00 find / -type f -size +100000

#??????????????shell?μ?jobs???????shell(???)???

c???????????л?????(fg????)
robin@SZDB:/tmp> fg            #???Job number?????Σ???????job?л?????
find / -type f -size +100000k
/u02/database/old/CNMMBOBK/undo/undotbsCNMMBOBK.dbf
......
[ctrl]+z
robin@SZDB:/tmp> fg %1
tar -czvf temp2.tar.gz tempSYBO2SZ.dbf
robin@SZDB:/tmp> jobs
[2]-  Stopped                 find /u02 -type f -size +100000k
[3]+  Stopped                 find / -type f -size +100000k

d?????к????????????(bg????)
#?????2??job????stopped???????????????????????У????????bg??????????job???????У?????????job?????????????job
robin@SZDB:/tmp> bg 2                    #????bg 2?????????????????????????&
[2]- find /u02 -type f -size +100000k &
robin@SZDB:/tmp> jobs
[2]-  Running                 find /u02 -type f -size +100000k &
[3]+  Stopped                 find / -type f -size +100000k

e?????????????n(kill)
robin@SZDB:/tmp> jobs
[3]+  Stopped                 find / -type f -size +100000k
robin@SZDB:/tmp> kill -9 %3      #??????job 3??????????%???????
robin@SZDB:/tmp> jobs
[3]+  Killed                  find / -type f -size +100000k
robin@SZDB:/tmp> jobs
#kill -9 ???????????????Job??-15???????????????????job?? kill -l ???г?kill??????????????
#????????????????????????? man command????????????

f??????shell???????????
#????????????????shell???
robin@SZDB:~/dba_scripts/custom/bin> more echo_time.sh
#!/bin/bash
SID=$1
sqlplus -Sscott/tiger@$1<<EOF
select to_char(sysdate??'yyyy-mm-dd hh24:mi:ss') today from dual;
begin
dbms_lock.sleep(300);
end;
/
select to_char(sysdate??'yyyy-mm-dd hh24:mi:ss') today from dual;
exit;
EOF
exit

#?????д??ε?shell???

# Author : Robinson
# Blog   :http://blog.csdn.net/robinson_0612

robin@SZDB:~/dba_scripts/custom/bin> ./echo_time.sh CNMMBO

TODAY
-------------------
2013-05-03 11:07:48

[1]+  Stopped                 ./echo_time.sh CNMMBO   #????[ctrl]+z?????л??????
robin@SZDB:~/dba_scripts/custom/bin> jobs
[1]+  Stopped                 ./echo_time.sh CNMMBO
robin@SZDB:~/dba_scripts/custom/bin> kill -9 %1       #????????job 

[1]+  Stopped                 ./echo_time.sh CNMMBO
robin@SZDB:~/dba_scripts/custom/bin> jobs             #?????job?????????killed
[1]+  Killed                  ./echo_time.sh CNMMBO
robin@SZDB:~/dba_scripts/custom/bin> ./echo_time.sh CNMMBO &  #??shell??????????? &???????job???????
[1] 2233
robin@SZDB:~/dba_scripts/custom/bin>         #?????????????????????????????????????
TODAY
-------------------
2013-05-03 11:08:25
 
robin@SZDB:~/dba_scripts/custom/bin> jobs
[1]+  Running                 ./echo_time.sh CNMMBO &
robin@SZDB:~/dba_scripts/custom/bin> ./echo_time.sh CNMMBO >temp.log 2>&1 &  #???????????????????????
[2] 2256
robin@SZDB:~/dba_scripts/custom/bin> jobs
[1]-  Running                 ./echo_time.sh CNMMBO &
[2]+  Running                 ./echo_time.sh CNMMBO >temp.log 2>&1 &

#?????????????????е????β?????????5????
robin@SZDB:~/dba_scripts/custom/bin> more temp.log

TODAY
-------------------
2013-05-03 11:09:24

PL/SQL procedure successfully completed.

TODAY
-------------------
2013-05-03 11:14:24