How to dealing with jobs

If you have started a huge process and just remember that you've forget do it in screen session, you may try to move this process to the background. You can do this by pressing ctrl+z keys, which will temporary block this process and then run bg, here is example:

We've run maldet command

$maldet -a ./

ctrl+z

Output:

[1]+  Stopped                 maldet -a ./

$job -l

Output:

[1]+ 793866 Stopped                 maldet -a ./

To bring a job into the background run:

$bg %1

Output:

[1]+ maldet -a ./ &

To bring a job back into the foreground run:

$fg %1

Once session into background run disown command:

$disown -h %1

If it doesn't work for you try to run disown with -a option it will remove all jobs from the table of active job

$disown -a

!Please note it will not give you 100% chance that process will be preserved after ssh session logout, so use screen instead ๐Ÿ™‚

Here is one more way how to manually switch process to background:

Identify firstly the PID of running process by running:

$ps auxfS |grep maldet

$kill -20 PID

$kill -18 PID

kill -20 will suspend your process
kill -18 will resume the process, in background.

You may see all kill's signal by running command:

$kill -l

 

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *