����Linux�Ż�
Linux����

shell-�����д򿪳���Ľ���

����ʱ��:2017-03-09 15:17:43��Դ:linux��վ����:root__1024
ͨ�������д�Ӧ�úܿ�ģ���ɾ����ݷ�ʽ�󣬱����õ���ĵ�����Ӧ�ö��򲻿���������һ���򵥵Ľű����Ǿ����˼����Ľ���
 
1��
ֻ��ʵ�ִ򿪳���Ĺ���
#!/bin/bash
echo "1.eclipse  2.firefox q:quit"
read -t 40 -p "input choice:" choice
case "$choice" in
"1")
#��eclipse
/home/SoftwareDev/eclipse/eclipse/eclipse
;;
"4")
#firefox
/usr/bin/firefox
;;
"q")
;;
*)
echo "input error!"
esac
�����
root@jimo:/home/workspace# ./open.sh 
1.eclipse  2.firefox q:quit
input choice:1
org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized.  Will retry ........
��û���⣬���Ǵ򿪵�Ӧ����terminal���ӽ��̣����Թر��ն˾ͻ�ر�Ӧ�ã���������ڴ򿪵ij������ʱ��Ϊ���أ��ܶ��ն�ȷʵ��̫�����
 
2��
������ͨ��nohup��Ӧ��ת���̨��
nohup ���� &
"1")
#��eclipse
nohup /home/SoftwareDev/eclipse/eclipse/eclipse &
;;
"2")
#firefox
nohup /usr/bin/firefox &
;;
�����ڴ�Ӧ�ú�Ϳ����ֶ��ر��ն��ˡ�
 
3��
���ǣ���Ϊϲ���Զ���������ô���ֶ��ر��أ�����̫low�ˣ����ǹ���һ��ʱ���ֽ������޸ģ�ͨ���ַ���ȡ���terminal��pid��Ȼ��ɱ���������ر��նˡ�
�ȿ������ȡ��pid
root@jimo:~# ps
PID TTY          TIME CMD
30942 pts/3    00:00:00 bash
30959 pts/3    00:00:00 ps
root@jimo:~# ps | grep bash
30942 pts/3    00:00:00 bash
root@jimo:~# ps | grep bash | awk '{print $1}'
30942
root@jimo:~#
ɱ����
kill -9 PID #-9����ǿ��ɱ����
����������������������ɫ��ѡ���
echo -e "\033[33m 1--->\033[0m Eclipse"
echo -e "\033[33m 2--->\033[0m firefox"
...
...
pid=$(ps | grep bash | awk '{print $1}')
kill -9 $pid
shell-�����д򿪳���Ľ���
 
�������ø��µ�ַ��//m.ajphoenix.com/linux/29044.html