UNIX Queue command execution


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users UNIX Queue command execution
# 1  
Old 05-30-2009
UNIX Queue command execution

Hello,

i was wondering if you could assist me in the following situation:

i am trying to queue a group execution commands (same command but different parameters) submited from an openVMS system to a Unix system (HP UX). The commands should run in sequence; the next starts after prev finish and only one running at a time. The commands are submitted from openVMS server in random order at any time. Notes: openVMS has queue functionality however is not an option in this case due to other reasons

So far the only option i see is writing a solution from scratch. generally speaking, this solution will involve copying the command as they come in from the openVms server into a file and having another process check this file for the next command insuring the commands are executed in FIFO order. the process will check the file continously or within specified constraint

this said, i was wondering if there are any unix commands that can do similar function or could help in this case?
# 2  
Old 06-02-2009
How does VMS "submit" the "job" to the UNIX server?
# 3  
Old 06-02-2009
the jobs are invoked using ssh sessions.

i was looking into command such as mkfifo however they only seralize the processes. ie it does not gaurantee one process will start after the prev finishes. i can only have process running at a time.
# 4  
Old 06-02-2009
Is each job submitted via it's own ssh process?
# 5  
Old 06-02-2009
yes. each is submited usinging its own ssh sessions. some of these jobs take 3 hours to complete which causes ssh session to timeout. Increasing the timeout period is not an option in this case. at the same time the rest of the job should be submitted provided nothing is running on the hpux server and this is basically the delima. i personally perfer the load and logic is moved to the hpux and the only role of the openvms server is just submitting jobs instead of waiting for the ssh session to complete.
# 6  
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question