If I have numerous jobs that rely on environment variables, how can I submit them sequentially? Here is my attempt that has not been working, week 6 is always submitted (and finishes) before week 5.


    (export id=me;
     export pass=welcome;
     export week=5;
     sas -log $HOME/logs/log$week.log sasjob.sas > /dev/null;
     export week=6;
     sas -log $HOME/logs/log$week.log sasjob.sas > /dev/null;
    ) &

I need the statements to run in exact sequential order on completion.


If I understand this correctly the following should do it:

for week in 5 6 ; do
    id=me pass=welcome week=$week \
        sas -log "$HOME/logs/log${week}.log" sasjob.sas
done >/dev/null &
  • I am still having difficulty getting this to work, I suspect because the job is that is being exited with jobcode 0 is really the submission of the script to sas... not the actual job itself. Do you see a reason this would/would not be the case? – mlegge Jun 23 '14 at 16:49
  • @mkemp6 - I'm sorry but I don't really. I was just trying to help. What happens if you remove the & and wrap the whole thing in { ... ; } &? As far as sas goes in particular, I'm a deadend for info there. I can usually help to some degree with shell stuff, but not much otherwise. – mikeserv Jun 23 '14 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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