Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm wondering if there's a practical purpose to the batch queue (i.e. batch, at -q b).

I'm asking this because there seems to be a mandatory 1 minute wait time (by atd's default) between consecutive job executions. (e.g. If I perform batch <<<true five times, it takes at least 4 minutes for the queue to clear.)

It seems unreliable to use in a production script because if some other user or script does something synonymous to for i in {1..2880}; do batch <<<true; done before mine, the execution of my scripts will be delayed/starved for 2 days.

share|improve this question
    
Maybe you should start by telling us what atd means in this context. I've done a quick search for atd and none of the results appear to be relevant to this question. –  John Gardeniers Aug 20 '12 at 5:12
    
@JohnGardeniers, man atd. –  Zoredache Aug 20 '12 at 7:28
    
@antak, IMO, just setup a cron job. These days I don't install atd. It isn't that useful 99% of the time. Your question is a bit badly asked though, and is likely to be closed. –  Zoredache Aug 20 '12 at 7:30
    
Not that this invalidates anything you say, but the interval can be set to be lower when atd is started with the -b flag. –  couling Sep 30 '12 at 13:38
add comment

1 Answer

up vote 3 down vote accepted

This command was more useful when the typical *nix machine had very few processors, but was heavily shared between users. As man batch states,

batch executes commands when system load levels permit; in other words, when the load average drops below 1.5, or the value specified in the invocation of atd.

So it was intended to be used in a resource-congested environment. If a job is started at a time when the load drops below the threshold, it makes sense for the system to watch how much load other users put in after completion of the job from the batch queue. Perhaps the load will rise above the threshold again, so execution of jobs from the batch queue needs to be suspended again. Hence the break.

Your counterexample is valid, but unrealistic. A user sabotaging the system like you describe is a "social problem", not a technical one. In case you think of an HPC environment where competing users submit loads of jobs: That's not what batch is for, this is, instead, the domain of tools like SLURM.

share|improve this answer
    
Thanks for the insight. I now understand the technical limitation and the need for the delay. (Although, the whole load average monitoring thing seems redundant with niceness. I dunno, maybe nicety scheduling isn't so infallible, or wasn't back then..) –  antak Aug 21 '12 at 0:35
    
As for the purpose, I tried to use batch as part of a package to perform asynchronous post-processing, namely for a backup module. e.g. Script gets called with file name, the file is hard-linked to a safe location and script returns more or less immediately. The file is compressed at a later time.) I thought batch was good for this, but since more than 60 files reach the system per hour, the queue just keeps stacking up. I did get around this by using one of the later letter queues (e.g. batch -q d), as they don't seem to have this 60 second wait. –  antak Aug 21 '12 at 1:08
    
Then why not just start atd with a shorter break interval, like 2 seconds? See its -b option in man atd. –  jstarek Aug 21 '12 at 8:45
    
Right. That's certainly an option, although it's one of the more intrusive ones. I guess that option would be a candidate if I was designing at the system level. Given the alternatives (e.g. not using the batch "b" queue), that level of interdependence didn't seem justified. OTOH, I would have happily used -q b if atd -b 2 was default. This question really came about from my inability to imagine 60 seconds being a practical default, and my curiosity to know the scenarios where somebody had in fact been able to use it practically nonetheless. –  antak Aug 21 '12 at 9:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.