473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to move job into background after already started

dlite922
1,584 Expert 1GB
i know to use nohup, but what if the user started a very long job and wanted to leave (logoff/logout) without killing the job.

Is there away to move an existing process into the background without restarting it?

This is a situation that came up by a colleague, but curious to know the answer for my future reference.


Thanks guys,


Dan
Jun 29 '10 #1

✓ answered by numberwhun

Also, if you are running a process from the command line and the command line is tied up by the process and you need it back, you can do a "ctrl-Z" and then type bg.

That will background the process you have running.

Regards,

Jeff

8 7352
AmberJain
884 Expert 512MB
You can either nohup or detach a process. You can try using some terminal multiplexer (google tmux or screen) and then detaching the terminal before you logout.
Jun 30 '10 #2
numberwhun
3,509 Expert Mod 2GB
Also, if you are running a process from the command line and the command line is tied up by the process and you need it back, you can do a "ctrl-Z" and then type bg.

That will background the process you have running.

Regards,

Jeff
Jun 30 '10 #3
dlite922
1,584 Expert 1GB
@numberwhun
But putting in in background then logging out, still keeps it going?

@Amber, ya, if it was a screen session, I could just detach it. Personally, I always use screen from my gateway host, but if I'm ever on some unusual host that away from our network doesn't have screen, I wouldn't know how to do it.

i'm going to test the bg method and log out, see if the job is still running. Will post back what I find.


Dan
Jun 30 '10 #4
dlite922
1,584 Expert 1GB
Worked!

Thanks @numberwhun


Dan
Jun 30 '10 #5
numberwhun
3,509 Expert Mod 2GB
Unfortunately, no, if you log out it probably won't keep going. Its not nohup. But, it does allow you to get our command prompt back.

Also, if you have a program that you know is going to hijack your prompt, then put a & at the end of the line like so:

Expand|Select|Wrap|Line Numbers
  1.  
  2. ./command -opt1 -opt2 &
  3.  
  4.  
That will automatically background the job and give you your prompt back immediately.

Regards,

Jeff
Jul 1 '10 #6
dlite922
1,584 Expert 1GB
that's weird, here's what I did. A php script that in a for loop writes a number to a text file every few seconds. I ran it, Ctrl+Z, then bg and logged off. (when it was at 10)

logged back in about half a minute later and tail -f 'd the file and it was in the 20's or something. It was obviously running when I was offline.

I'll reconfirm and log off for a greater period or log in from another user's and follow the text file.

I'm pretty sure it kept running.


Dan
Jul 1 '10 #7
numberwhun
3,509 Expert Mod 2GB
That is weird because ctrl-z is an interrupt.
Jul 1 '10 #8
ashitpro
542 Expert 512MB
try 'setsid' command...
It will create a process which will run your job and its parent will be init.
I am not sure about behavior after logoff.
But theoretically it should work as we are assigning it to init.
Jul 6 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Jerry | last post by:
Hi All How can I produce an output to the browser and let the script continue to work in the background, producing a later screen output? Example: Trigger a database search so that the user...
4
by: Q | last post by:
Hello, I have composed the following simple php file: <html> <head><title> Title. </title></head> <body> <?php header("Location: http://www.something.com/tmp2.php"); ?> </body>
5
by: Philip Ronan | last post by:
OK, here's my 2p worth: === Q. Why am I getting the error message 'Headers already sent'? A. PHP produces this error message when you try to set a header for a web page after you have already...
1
by: sarmin kho | last post by:
Hi Pythoners... I am building a python GUI with wxpython... the python GUI will periodically call a python module written on python 2.2... wxtimer is used to enable the periodic call... it works...
2
by: Stephan Brunner | last post by:
https://beta.microsoft.com tells me that there are NO Enrolled betas Am I in the wrong movie? Where is the official place for VS 2005 / Framework 2.0 Beta 1 testers?
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
14
by: Alex K. | last post by:
Hi all I'd like to avoid starting the same c# application twice on the same computer. How do I check if it is already running? Thank you
1
by: adept | last post by:
I try to do it in this way: it is reaction on event OnLoad cpr = Process.GetCurrentProcess(); Process spr = Process.GetProcessesByName(cpr.ProcessName); ...
20
by: Alexey Kulentsov | last post by:
Hi all! Windows XP, Apache 2.2, PHP 5.2.5 as apache module (php5apache2_2.dll) I need to run background process and see output but for current moment all methods runs it as process not as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.