PSSH heavy process in background

476 views
Skip to first unread message

Mateusz Harasymczuk

unread,
Sep 2, 2011, 7:27:43 AM9/2/11
to parall...@googlegroups.com
I would like to run a heavy process in background on each of my servers.

I have this thread

pssh  -x "-T" -h hosts.conf --send-input --timeout 0 --inline << EOF

function thread {
  if [ ! -d dest ]; then
     echo -n "cloning repository... "
     git clone (very large repo) dest
     echo "done."
     exit 0
  else
     echo "repo exists"
     exit 1
  fi
}

thread &
echo "Thread is running..."
exit 0
EOF


However it waits until it finishes job.
Do you have any idea how to do that?

Félix Ortega Hortigüela

unread,
Sep 2, 2011, 7:46:43 AM9/2/11
to parall...@googlegroups.com
Hi.
Here we have the same problem, and we launch the process with "at" comand:

pssh  -x "-T" -h hosts.conf --send-input --timeout 0 --inline << EOF
echo 'function thread {

  if [ ! -d dest ]; then
     echo -n "cloning repository... "
     git clone (very large repo) dest
     echo "done."
     exit 0
  else
     echo "repo exists"
     exit 1
  fi
}

thread' | at now+1minute

echo "Thread is running..."
exit 0
EOF

If you want to know the status of the command you need some kind of logging, but it works.

Regards.
--
Félix Ortega Hortigüela

Andrew McNabb

unread,
Sep 2, 2011, 12:02:07 PM9/2/11
to parall...@googlegroups.com
On Fri, Sep 02, 2011 at 01:46:43PM +0200, Félix Ortega Hortigüela wrote:
> Here we have the same problem, and we launch the process with "at" comand:

That's a good suggestion. You can also try looking at "screen" and
"nohup". All of these approaches have different pros and cons.

--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868

Félix Ortega Hortigüela

unread,
Sep 13, 2011, 4:08:40 AM9/13/11
to parall...@googlegroups.com
There is a new command I've discovered yesterday for doing this. The
"disown" builtin from bash is a nohup for a running process. You can
do something like that:

function thread {
if [ ! -d dest ]; then
echo -n "cloning repository... "
git clone (very large repo) dest
echo "done."
exit 0
else
echo "repo exists"
exit 1
fi
}

thread &
echo "Thread is running..."

disown -a
exit 0
EOF

And the process will be left running when you close the session.

Regards.
--
Félix Ortega Hortigüela

Reply all
Reply to author
Forward
0 new messages