Sponsored Content
Full Discussion: UNIX Queue command execution
Top Forums UNIX for Advanced & Expert Users UNIX Queue command execution Post 302323280 by otheus on Saturday 6th of June 2009 08:43:15 AM
Old 06-06-2009
I waited a few days to let others give a try at this. Here are some possibilities:

1. Use batch which comes along with at. If atd is not running, ask your sysadmin about this. I've access to the Linux version which might be completely different than the AIX version.

With batch you give it the commands from standard input. It queues the commands to run (by atd) when the system load average is below a threshold (specified by atrun or atd).

Cons: Your jobs might not affect load, so this might be useless. A job might suddenly become IO bound, fooling atd to run the next program.

2. SGE - Sun Grid Engine. It's a full-featured batch submission engine, but it might be overly complex for this kind of application. On the other hand, it's relatively easy to set up.

3. Custom queue:

Instead of the command actually doing the work, override it with a shell function that outputs the command and parameters to a FIFO. Here's the gist of this:

Code:
umask 077
mkdir -p $HOME/var/run
mkfifo $HOME/var/jobq

Now create a cronjob (to run every minute) to read the queue and execute the next command, as long as the previous is not still running:
Code:
* * * * *  $HOME/bin/batch_execute.sh

in $HOME/bin, you can create the script:
Code:
#!/bin/sh

# If another job is running, exit immediately
test -f $HOME/var/run/jobq.lock && exit 0

# lock the queue (exit with 256 on failure)
touch $HOME/var/run/jobq.lock || exit 256

# read the queue
read job < $HOME/var/run/jobq

# run the program
eval $job

# remember job's exit status
status=$?

# remove the lock when done
rm -f $HOME/var/run/jobq.lock || exit 257

# exit with job's exit status
exit $status

There is a big problem with this scheme, however: the writers will block until the reader is available. So the job submitter must go into the background until the reader is available. Here's such a job-submitter.
Code:
#!/bin/sh
# submit.sh
echo $* > $HOME/var/run/jobq &

Prefix all your jobs with this "submit" script (which should be in your PATH or hard-coded as something like $HOME/bin/submit.sh).

I haven't tested this, and there maybe some problems. But give it a try.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

setup unix workstation to print on NT queue ?

how do I setup my unix workstation to print to NT Printer server queue? any helps greatly appreciated. I can setup print staight to printer, however, I can not print it to NT server queue. thanks, (1 Reply)
Discussion started by: phapvn
1 Replies

2. UNIX for Advanced & Expert Users

Unix message Queue

Hi, I am working closly with unix message queues i have encountered the following - after creating the Q and start working with it (pushing & pulling) i receive the following stange parameters on the q's - STIME=no_entry Qnum=0 CBYTES=4140 when this happens, the Q is disabled (meaning i... (3 Replies)
Discussion started by: kel
3 Replies

3. Filesystems, Disks and Memory

Unix hash queue

How is the hash queue categorized? I am trying to understand the free list vs the hash queue and i'm just not getting it. The book im using is written like you already have a degree in Unix architecture. Maybe someone knows a web site that explains this in laymans terms. A Unix architecture for... (1 Reply)
Discussion started by: HPCnewbie
1 Replies

4. Linux

unix command for multifile program execution

how can I compile and execute multifile program in unix os.:o (0 Replies)
Discussion started by: alokmishra8
0 Replies

5. Programming

UNIX Message Queue

Hello !!!!! I have a simple question but i can't find the answer anywhere hope to meet it here. Why it is a bad idea to pass pointers through message queues ? Most structs i see all of their char types are arrays... Is it becase having pointers means we could possibily send wrong bytes ? For... (2 Replies)
Discussion started by: qlyine
2 Replies

6. Solaris

Program execution order like FIFO queue

Hi all: I have a problem with a C++ service runing on solaris 10. This service only set a signal on oracle table. When the service detect a cut off on the line (tcp/ip), trigger a cobol program for set the signal OFF. When the line is on again, the service trigger the same cobol program for set... (0 Replies)
Discussion started by: hcastellani
0 Replies

7. UNIX for Dummies Questions & Answers

UNIX command to skip any warning messages and continue job execution

Hello All, Good day! This is my first UNIX post. :D Anyways, I would like to seek help from you guys if you know of any UNIX command that will skip a warning message once it is encountered but continue to run the execution. Ok here's the situation in general: An encypted file is sent to... (2 Replies)
Discussion started by: jennah_rekka
2 Replies

8. Shell Programming and Scripting

Remote access and command execution on unix platform

How can we create new directory/Or execute command on remote unix machine from another unix machine. We can use SSH command to execute command on remote machine but problem is that ssh will prompt for password before executing command. My requirment is to execute command without manual... (1 Reply)
Discussion started by: pasricha.kunal
1 Replies

9. Shell Programming and Scripting

How to simulate an execution queue with bash?

I'm running cygwin bash on windows 7 and I'm have some bat files that perform large builds and take a long time and a lot of memory. Therefor, I don't want to builds executing simultaneously (too much memory). How can I implement a queue so I can queue up multiple builds and only execute one... (2 Replies)
Discussion started by: siegfried
2 Replies

10. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies
Sendpage::Queue(3pm)					User Contributed Perl Documentation				      Sendpage::Queue(3pm)

NAME
Queue.pm - implements a simple directory-based file queue SYNOPSIS
$queue=Sendpage::Queue->new($dir); while ($queue->ready()) { $filename=$queue->file(); $fh=$queue->getReadyFile(); if ($can_remove_file) { $queue->fileToss(); } else { $queue->fileDone(); } } # open a new queue file $fh=$queue->getNewFile(); # ... do things to the file handle here # release the file $queue->doneNewFile(); DESCRIPTION
This is a module for use in sendpage(1). BUGS
Need to write more docs. AUTHOR
Kees Cook <kees@outflux.net> SEE ALSO
perl(1), sendpage(1), Sendpage::KeesConf(3), Sendpage::KeesLog(3), Sendpage::Modem(3), Sendpage::PagingCentral(3), Sendpage::PageQueue(3), Sendpage::Page(3), Sendpage::Recipient(3) COPYRIGHT
Copyright 2000 Kees Cook. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2008-01-03 Sendpage::Queue(3pm)
All times are GMT -4. The time now is 02:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy