1

My team's using Pallet (think Puppet in Clojure) to automate server provisioning, but running into a fairly fundamental problem: Pallet can execute arbitrary scripts directly on target VMs, but if one of those scripts happens to put a command in the background, it simply isn't executed. At least, not in the way we're trying to engineer things.

We've tried this using & and screen, with the latter being the ideal, and neither works. For example, we've tried getting Pallet to execute the following script on the target VM...

touch a
touch b &
touch c

and all we see remotely is that files a and c exist. The shell (or do I mean process?) in which the main script executed simply refused to execute 'touch b'. On the other hand, if we execute this script with an ordinary terminal session on the same host, it works fine.

Of course, we're attacking this from the Pallet angle. But in case that doesn't bear fruit, can someone tell me under what kinds of circumstances a shell would refuse to execute a backgrounded process, in case it gives us a clue for a workaround?

We're using CentOS 6.5 64 bit, though I expect that's not relevant.

  • It turns out that the parent process was ending before the child process had time to detach. set -m or #!/bin/bash -m enables bash job control, and that was enough to get everything working. – Jon Woods May 27 '14 at 14:15
2

Try:

touch b & disown

Maybe child processes get killed by a signal because parent process exit. Use help disown to see what disown does.

There separate nohup program which does the same, but this would work under any shell:

nohup touch b
  • This looks like a great way to find out what was going wrong - thanks. I've just solved anyway (see comment on question) but this would have been a great help. Sorry I can't up-vote your answer; I'm new. – Jon Woods May 27 '14 at 14:09

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.