Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Difference between batch and &' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Difference between batch and &
Authored by: triplef on Jan 22, '03 06:31:54PM

Is there any difference between using batch and using the "&" postfix in bash?
I would do it like this:
sudo fink -y update-all &
... and the command will happily run in the background.

Maybe I'm missing something.



[ Reply to This | # ]
Difference between batch and &
Authored by: Tiresias on Jan 22, '03 09:38:25PM

I haven't used unix stuff for long enough so I don't know but I think that when you use & you still own it. If I read it correctly, this method runs things as root which means your user doesn't have to be logged in.



[ Reply to This | # ]
Difference between batch and &
Authored by: sardu_mac on Jan 23, '03 06:55:16AM
It doesn't run the command 'as root' but rather the userid that executed the command. It also retains things like environment variables and current working directory

From the manpage:
For both at and batch, the working directory, environment (except for the
variables TERM, TERMCAP, DISPLAY, and _) and the umask are retained from
the time of invocation. The user will be mailed the standard output and
standard error from his commands if any output is generated. If at is
executed from a su(1) shell, the owner of the login shell will receive
the mail.


[ Reply to This | # ]
Difference between batch and &
Authored by: GEllenburg on Jan 23, '03 07:01:53AM

The `batch` command does one other important thing which using the ampersand operater can not...

One can queue up tens, or even hundreds of commands to run "... in batch ...," but if the load average on the machine is too high, batch will wait for the load to drop down before executing further commands so the system doesn't become unstable or unusable.

Simply placing a command in the background (using the ampersand) can't do this.



[ Reply to This | # ]
Difference between batch and &
Authored by: sardu_mac on Jan 23, '03 06:58:58AM

Using & executes right away, rather than, say, updating fink at 3:00AM when you won't miss the extra CPU cycles.



[ Reply to This | # ]