Re: parallel bash scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27Mar2012 17:56, Rick Stevens <rstevens@xxxxxxxxxxxxxxxxxxx> wrote:
| On 03/27/2012 04:06 PM, bruce wrote:
| The problem is that a script wants a stdin, stdout and stderr.

No evidence so far that they use stdin.

| If
| you're going to run them in parallel, you can't very well have both
| scripts outputting to the terminal.

Sure you can. Why not? I do it all the time with multiple tails etc.

| The correct thing is to do what Dave said. Use nohup and redirect stdout
| and stderr to a log file. You can then "tail -f" each one whenever you
| want.

Background and disown is better, usually. I'm finding nohup more and
more painful; always the same output file, stdout and stderr glommed
together etc.

| An alternative is to launch the scripts in detached screen
| sessions:
| 
| 	screen -d -m dog.sh
| 	screen -d -m cat.sh
| 
| This would launch each script in its own detached screen session
| (essentially creates virtual terminals with shells and runs the script
| in them) and the calling script doesn't wait for them to complete.

You can get screen session names, too. Much easier to work with than the
ids you get by default.

  % screen -ls
  There are screens on:
        2635.GETMAIL    (Detached)
        17863.CP_VIDEO  (Detached)
        6557.OI (Detached)
        1247.BACKUP     (Detached)
        2203.BEYONWIZ   (Detached)
        9125.EMERGE     (Detached)
        15806.mutt-28mar2012-16:23 Re_parallel_bash_scr (Attached)
  7 Sockets in /tmp/screen-cameron.

That last is actually the email editor I'm using right now. Can detach
and pick up again later!

But:

  dog.sh </dev/null >dog.out 2>dog.err &
  cat.sh </dev/null >cat.out 2>cat.err &
  disown %1 %2

is simple and basic. Adjust %1 and %2 to the job numbers you get; see the
"jobs" command to get current background jobs.

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

To understand recursion, you must first understand recursion.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux