Job management in Linux system

1 Understand the job
  When you open vim with enthusiasm and start writing code. Operation mm ran over breathlessly: "Hurry up and run a xx data for me, I will use it for the meeting tomorrow." But I didn't want to close vim, and I couldn't open a new tty under some systems. What to do, can it only be ? In fact, your current tasks and the tasks that the operation mm wants you to do are all jobs. Each job corresponds to a subprocess in bash, and the management of the job is the management of the process. Then look down.


2 To suspend a job
, you can use the ctrl+z shortcut to suspend the editing task in the background, and the terminal displays the status of that task as stopped or stopped. In this way, you can help the operation MM run the data, .


3 Put the job to run in the background
  or you will encounter such a situation. When running a very time-consuming task, the operation mm comes again, "Help me run a copy of xx data, which will be used for the meeting in the afternoon." Don't worry, you can use this:&. When executing a command, append & to make your job run in the background. View the cp task through the jobs command, and the task status is running.


4 Return the job to the front desk The
operation mm has finally left, what should you do if you want to continue working? You can execute the fg command to bring a task suspended in the background back to the foreground. The job with + sign is taken out by default. If you want to take out the job with - sign, you can do this: fg %1 (1 is the number of the job).


5 Change the status of the job running in the background
  When you use ctrl+z to suspend the task, but you don't want it to be idle, what should you do? You can use the bg command to change the running status of the job. The task will become Running or Running, followed by an ampersand.


6 Killing a job
  If there are many tasks suspended or running in the background, and you want to close some tasks, you can execute kill -9 %jobnumber.


Write these first, and collect them if you like.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326355201&siteId=291194637