You guys probably knew already, but me just figured out how to get the return value of job running/ran in background.
For some weird reason it didnt want to work with an exported variable.
This one will write the exit code to a temp file, so it can be easy retrieved after the loop is done.
Where $JOB is a scriptfile containg the command to execute and $TEMP_FILE is a pre-set var (like: /tmp/tmp.ret)
Now to use that retvar in a variable again is easy:
Et voila
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT PHP
gearmanclient.dobackground
GEARMANCLIENT.DOBACKGROUND(3) 1 GEARMANCLIENT.DOBACKGROUND(3)GearmanClient::doBackground - Run a task in the background
SYNOPSIS
public string GearmanClient::doBackground (string $function_name, string $workload, [string $unique])
DESCRIPTION
Runs a task in the background, returning a job handle which can be used to get the status of the running task.
PARAMETERS
o $function_name
- A registered function the worker is to execute
o $workload
- Serialized data to be processed
o $unique
- A unique ID used to identify a particular task
RETURN VALUES
The job handle for the submitted task.
EXAMPLES
Example #1
Submit and monitor a background job
The worker in this example has an artificial delay introduced to mimic a long running job. The client script periodically checks
the status of the running job.
<?php
/* create our object */
$gmclient= new GearmanClient();
/* add the default server */
$gmclient->addServer();
/* run reverse client */
$job_handle = $gmclient->doBackground("reverse", "this is a test");
if ($gmclient->returnCode() != GEARMAN_SUCCESS)
{
echo "bad return code
";
exit;
}
$done = false;
do
{
sleep(3);
$stat = $gmclient->jobStatus($job_handle);
if (!$stat[0]) // the job is known so it is not done
$done = true;
echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denomintor: " . $stat[3] . "
";
}
while(!$done);
echo "done!
";
?>
The above example will output something similar to:
Running: true, numerator: 3, denomintor: 14
Running: true, numerator: 6, denomintor: 14
Running: true, numerator: 9, denomintor: 14
Running: true, numerator: 12, denomintor: 14
Running: false, numerator: 0, denomintor: 0
done!
SEE ALSO
GearmanClient::doNormal, GearmanClient::doHigh, GearmanClient::doLow, GearmanClient::doHighBackground, GearmanClient::doLowBackground.
PHP Documentation Group GEARMANCLIENT.DOBACKGROUND(3)