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

How to use the disown command in Linux

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

Share

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

Editor to share with you how to use the disown command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The Linux common command disown command can remove all jobs from the job list of the current shell, or remove one or more specified jobs; you can also remove running jobs; or you can mark jobs so that they do not end after the current shell exits.

Syntax format disown [parameter] [identifier or process ID]

Common parameter:-h marks each job identifier, these jobs will not receive sighup signal when shell receives sighup signal-a remove all jobs-r remove running job # instance

# Demo. Ssh 192.168.1.4 user2@192.168.1.4's password: # Press ctrl+z at this time to stop the interaction. [1] + Stopped ssh 192.168.1.4 ssh 192.168.1.7 user2@192.168.1.7's password: # press ctrl+z at this time to stop the interaction. [1] + Stopped ssh 192.168.1.7 sleep 120 & [3] 28986 # list jobs and pid information. Jobs-l [1]-28756 Stopped ssh 192.168.1.4 [2] + 28833 Stopped ssh 192.168.1.7 [3] 28986 Running sleep 120 & # deletes a running job. Disown-r jobs-l [1]-28756 Stopped ssh 192.168.1.4 [2] + 28833 Stopped ssh 192.168.1.7 # Note disown only removes jobs and does not stop. Pgrep-a-u user2-f 'sleep 120' 28986 sleep 120 # deletes the specified job. Disown% 2 bash: warning: deleting stopped job 2 with process group 28833 jobs-l [1]-28756 Stopped ssh 192.168.1.4 # Note disown only removes jobs and does not stop. Pgrep-a-u user2-f 'ssh 192.168.1.7' 28833 ssh 192.168.1.7 # Delete all jobs. Disown-a bash: warning: deleting stopped job 1 with process group 28756 jobs-l # Note that disown is just removing the job, not stopping it. Pgrep-a-u user2-f 'ssh 192.168.1.4' 28756 ssh 192.168.1.4 # demonstrate the effect of the-h option. Sleep 90 & [1] 109080 jobs-l [1] + 109080 Running sleep 90 & disown-h% 1 exit # at this time the previous terminal has been closed, now open a new terminal to look for the job. Pgrep-a-u user2-f 'sleep 90' 109080 sleep 90 editor

Note that bash's job control commands include bg fg kill wait disown suspend.

This command needs to be executed when the set option monitor is on; to view the job control status: type set-o to view the monitor line; execute set-o monitor or set-m to turn on this option.

This command is a bash built-in command. For help, please see the help command.

The above is all the contents of the article "how to use disown commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report