I'm pretty sure I had the answer to this months ago and have misplaced it. Needless to say I will bookmark it this time.
I have a background process that's been running way longer than usual. It doesn't output anything to a file, so I can't 'tail -f' it. Is there a command that will enable me to see the output the process would be sending to the screen if it was not in the background?
Thanks.
I have a process originally running in the foreground.
Say I start a process in the terminal and it sends output to standard error while it runs. I want to move the process into the background and also silence it at the same time.
Is there a way to do this without stopping the process and starting it again using & and > /dev/null 2>&1 ?
Hii Friends,
I am using Perl CGI. I am running A SCP Command via Perl CGI in Background. Like
Code:
system("scp -r machinename:/PathOfFile/ /Path/WhereToCopyIt/ &)
This Copy Process takes some times lets say 15 min.
I have Process Id for one background process and currently it is running state. I want to see the return code after the above running process is done.
for the forground process normally I use "echo $?". But how to get the return code for my background process on UNIX/Linux??
Thanks in advance!
Sriram
I know that you can use this to start a process in the background, without getting the notification when the process is put in the background and when it is done like so:
(command &) &> /dev/null
However this removes the option to trap when the process finishes (trap child_done CHLD).
How can I have both?
2 questions:
1) Is there any Linux/Posix API to know if a process has been invoked as a background process?
linux> myprogram &
Can the code for myprogram detect that it has been invoked to run in the background (via &) ?
2) Is there any Linux/Posix API to make a process run in the background even if it has been started as a foreground process? I.E.
I've started a long running and machine hog process. I've hit CTRL-Z to stop it. I've then put it in the background with bg. Oops, I should have restarted with fg so that I could easily stop and start it again. What is the easiest way to stop a process that was just put into the background?
I want to run a command sudo apt-get update &. However after hitting enter, when i hit for jobs, it shows the status of these commands as stopped. My guess is that by pushing the process into background I did not provide it an opportunity to ask password. Is there a way to run a process in background which requires a password ?