[ale] sometimes I hate bash

Ed Cashin ecashin at noserose.net
Wed Dec 16 20:32:19 EST 2009


On Wed, Dec 16, 2009 at 6:49 PM, Jim Kinney <jim.kinney at gmail.com> wrote:
> script runs all hunky-dorey in userland.
>
> so time to put it into cron. To cover my bases for inferior cron
> environemnt, the first thing the script does is . ~/.bash_profile which in
> turn runs ~/.bash_rc which runs /etc/bashrc

If you are "running" scripts, you're creating new bash processes, but
if you use exec instead, you'll replace the running process with a new
one.

ecashin at Ed-Cashins-MacBook-Pro ~$ cat /tmp/count-procs
#! /bin/sh
ps ax | wc -l
ecashin at Ed-Cashins-MacBook-Pro ~$ cat /tmp/test-run
/tmp/count-procs
ecashin at Ed-Cashins-MacBook-Pro ~$ sh /tmp/test-run
      52
ecashin at Ed-Cashins-MacBook-Pro ~$ cat /tmp/test-exec
exec /tmp/count-procs
ecashin at Ed-Cashins-MacBook-Pro ~$ sh /tmp/test-exec
      51
ecashin at Ed-Cashins-MacBook-Pro ~$

...
> Except somehow it now spawns _2_ copies of the running process and the race
> is on! <insert appropriate swearing here>

Do the above comments seem relevant?  I can't really tell if that's all
there is to it.

-- 
  Ed Cashin <ecashin at noserose.net>
  http://noserose.net/e/
  http://www.coraid.com/


More information about the Ale mailing list