10-09-2013
You can use $! to get the PID of the last started background process.
You can also use jobs %1 to get the status of the job (testing it with $?), and kill %1 to kill it.
This User Gave Thanks to Scott For This Post:
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hiya,
Recently I've run a few scripts in the foreground, but have realised later they should of been better nohup'd and placed in the background. I understand how to change a foreground job into a background one, but how would put the job into the nohup state?
Thanks (1 Reply)
Discussion started by: rdbooth
1 Replies
2. Shell Programming and Scripting
Hi all,
I am running a job .. and i want to know the status tht it is runnig or not ..
and how can i find the jobId of my job ..
I have to get it to kill my running job
Pls let me know da Unix commands to do it ..
i m wrking on Hp UNIX (1 Reply)
Discussion started by: ravi.sadani19
1 Replies
3. Shell Programming and Scripting
I have run one shell script in background that contains a endless while loop.
I am not able to know the status of that job .
Please provide any command to know this. I have already used "ps -aef" , "jobs" to know it , but it didn't work. I am sure the process is running as it is generating a file... (8 Replies)
Discussion started by: sumanta
8 Replies
4. AIX
Guys,
We use AIX 5.3 at our work place. I only in my team have a strange problem of not able run jobs background. Other colleagues are able to run without any problem.
Once I kick off background job using nohup and & command, It immediately stops. The following error I get when I run.
... (2 Replies)
Discussion started by: anandsbr
2 Replies
5. UNIX for Dummies Questions & Answers
Hello,
I am running a shell script whose execution often takes several hours to complete. Is there way I can get some kind of status update as the job is running? Something as simple as the start and the current time stamp.
Thanks,
Gussi (2 Replies)
Discussion started by: Gussifinknottle
2 Replies
6. Shell Programming and Scripting
Hi All,
I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script.
Is there a way I can capture the exit status of each individual child script after the execution is completed. (2 Replies)
Discussion started by: paragkalra
2 Replies
7. UNIX for Dummies Questions & Answers
Is there a way to suspend (TSTP?) a job that is running in the background, _without_ first bringing it to the foreground and inputting Ctrl-Z from the keyboard?
IOW, something similar to issuing the shell's bg builtin command on a job ID to resume a job that is suspended in the background,... (2 Replies)
Discussion started by: uiop44
2 Replies
8. Shell Programming and Scripting
Hello Everyody,
Having a doubt.
sort file1 &
when we sent a job to the background it returns
Job Number
PID
again if we want to ... (1 Reply)
Discussion started by: knroy10
1 Replies
9. Solaris
Hi,
Should the user jobs specified in crontab be running in background?
Cron daemon is already running in background. So I am not sure
whether should the jobs (output and error messages are redirected to file)
ran by it be explicitly stated to be run in background (& at end of command)
if one... (1 Reply)
Discussion started by: joe_x
1 Replies
10. Shell Programming and Scripting
Hi,
I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help..
i am using below command to run script
nohup system_traps.sh &
but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies
bg(1) General Commands Manual bg(1)
NAME
bg - Runs jobs in the background
SYNOPSIS
bg [job_id...]
Note
The C shell has a built-in version of the bg command. If you are using the C shell, and want to guarantee that you are using the command
described here, you must specify the full path /usr/bin/bg. See the csh(1) reference page for a description of the built-in command.
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
bg: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
None
OPERANDS
Specifies the job to be resumed as a background job. If no job_id operand is given, the most recently suspended job is used. The format of
job_id is described in the Jobs section of the ksh(1) reference page.
DESCRIPTION
If job control is enabled (see the description of set -m in the ksh(1) reference page), the bg utility resumes suspended jobs from the cur-
rent environment by running them as background jobs. If the job specified by job_id is a job already running in the background, the bg
utility has no effect and will exit successfully.
Using bg to place a job into the background causes its process ID to become "known in the current shell execution environment", as if it
had been started as an asynchronous list. See the Jobs section of the ksh(1) reference page.
RESTRICTIONS
If job control is disabled, the bg utility exits with an error and no job is placed in the background. The bg utility does not work as
expected when it is operating in its own utility execution environment because that environment has no suspended jobs.
EXIT STATUS
The following exit values are returned: Successful completion. An error occurred.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of bg: Provides a default value for the internationalization variables that are
unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari-
ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value,
overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes
of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale used to
affect the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the
processing of LC_MESSAGES.
SEE ALSO
Commands: csh(1), fg(1), jobs(1), kill(1), ksh(1), Bourne shell sh(1b), POSIX shell sh(1p), wait(1)
Standards: standards(5)
bg(1)