Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Cloud Computing Learning Route course syllabus material: homework Control jobs

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Today, I would like to share with you some course outline materials on cloud computing learning routes. This article is about some learning notes on homework control jobs. I hope I can give you some help:

Job control is a command-line feature that allows a single shell instance to run and manage multiple commands.

If there is no job control, the parent process fork () after a child process, sleeping until the child process exits.

Using job control, you can optionally pause, resume, and run commands asynchronously so that shell can return to accept other commands while the child process is running.

Foreground, background, and controlling terminal

Foreground: a foreground process is a command that runs in a terminal, which is the control terminal of the process. The foreground process receives the input and signal generated by the keyboard and allows reading or writing from the terminal to the terminal.

Background: the background process does not control the terminal, it does not require terminal interaction.

Example 1:

[root@tianyun ~] # sleep 3000 & / / run the program and let it execute in the background

[root@tianyun ~] # sleep 4000 / / ^ Z, suspend (pause) the program in the foreground to the background

[2] + Stopped sleep 4000

[root@tianyun ~] # ps aux | grep sleep

Root 8895 0.0 0.0 100900 556 pts/0 S 12:13 0:00 sleep 3000

Root 8896 0.0 0.0 100900 556 pts/0 T 12:13 0:00 sleep 4000

[root@tianyun ~] # jobs / / View background jobs

[1]-Running sleep 3000 &

[2] + Stopped sleep 4000

[root@tianyun ~] # bg% 2 / / Let Job 2 run in the background

[root@tianyun ~] # fg 1 / / transfer Job 1 back to the foreground

[root@tianyun ~] # kill 1 / / kill 1, terminate the process with PID 1

Preview:

[root@tianyun] # (while:; do date; sleep 2; done) & / / the process runs in the background, but the output is still on the current terminal

[root@tianyun] # (while:; do date; sleep 2; done) & > / dev/null &

& the backstage character is placed at the end of the command

Example 2: how to manage remote hosts

[root@tianyun ~] # ssh 10.18.40.100

[root@www ~] # yum-y install screen / / for the first time

[root@www] # screen-S install_apache

Reconnect after disconnection = =

[root@www ~] # screen-list

There are screens on:

28958.install_nginx (Detached)

29013.install_apache (Detached)

2 Sockets in / var/run/screen/S-root.

[root@www] # screen-r 29013

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report