in reply to running a cmd in background and capturing the output

Also i need to capture the output of this command to a file.

If you just need the command output in a file and not using it elsewhere in your script, you could just pipe the output of the command to the file named "file.txt". For example, your sample code appears to be calling the command du /usr/bin. You could modify it to be du /usr/bin > file.txt to pipe the STDOUT to a file.

If you do need the output in other parts of your script, then I personally would do this using threads. To go that route, I would probably create a subroutine that expects a directory as input and returns the output of the running the du command on that directory. Then you call that routine in a thread.

Just tossing out a few other suggestions.