linux 下,如何把命令放入后台
加 &即可
sleep 100000 &
[root@rac1 ~]# sleep 100000 &
[2] 4591
要查看有一些 job
jobs
[root@rac1 ~]# jobs
[1]- 运行中 sleep 10000 &
[2]+ 运行中 sleep 100000 &
要让后台进入前台
fg %job number
[root@rac1 ~]# fg %2
sleep 100000
让前台进入后台
ctrl+z
[root@rac1 ~]# fg %2
sleep 100000
^Z
[2]+ 已停止 sleep 100000
查看job信息
ps j
[root@rac1 ~]# ps j
PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
1632 1639 1639 1639 tty1 1639 Ssl+ 0 0:01 /usr/bin/Xorg :0 -background none -verbose -auth /run/gdm/auth-for-gdm-REYLZN/database -seat seat0 -no
2170 2467 2467 2467 pts/0 3074 Ss 0 0:00 -bash
2467 3039 3039 2467 pts/0 3074 S 0 0:00 su - oracle
2170 4244 4244 4244 pts/1 5405 Ss 0 0:00 -bash
4244 4591 4591 4244 pts/1 5405 T 0 0:00 sleep 100000
4244 5405 5405 4244 pts/1 5405 R+ 0 0:00 ps j
重启这个 job 进程到后台,使用 bg %job number
bg %2
[root@rac1 ~]# bg %2
[2]+ sleep 100000 &
[root@rac1 ~]# ps j
PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
1632 1639 1639 1639 tty1 1639 Ssl+ 0 0:01 /usr/bin/Xorg :0 -background none -verbose -auth /run/gdm/auth-for-gdm-REYLZN/database -seat seat0 -no
2170 2467 2467 2467 pts/0 3074 Ss 0 0:00 -bash
2467 3039 3039 2467 pts/0 3074 S 0 0:00 su - oracle
2170 4244 4244 4244 pts/1 5620 Ss 0 0:00 -bash
4244 4591 4591 4244 pts/1 5620 S 0 0:00 sleep 100000
4244 5620 5620 4244 pts/1 5620 R+ 0 0:00 ps j
[root@rac1 ~]#
欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) | Powered by Discuz! X3.2 |