sem: --shebang-wrap example in manual.

This commit is contained in:
Ole Tange 2015-01-02 11:33:40 +01:00
parent 44d5283151
commit 303bc5f465
2 changed files with 35 additions and 1 deletions

View file

@ -955,7 +955,7 @@ sub parse_options {
sub init_globals { sub init_globals {
# Defaults: # Defaults:
$Global::version = 20141229; $Global::version = 20150101;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$Global::infinity = 2**31; $Global::infinity = 2**31;
$Global::debug = 0; $Global::debug = 0;

View file

@ -1534,6 +1534,9 @@ On FreeBSD B<env> is needed:
debian.org debian.org
freenetproject.org freenetproject.org
There are many limitations of shebang (#!) depending on your operating
system. See details on http://www.in-ulm.de/~mascheck/various/shebang/
=item B<--shebang-wrap> =item B<--shebang-wrap>
@ -3010,6 +3013,37 @@ same time:
seq 3 | parallel sem --id mymutex sed -i -e 'i{}' myfile seq 3 | parallel sem --id mymutex sed -i -e 'i{}' myfile
=head1 EXAMPLE: Mutex for a script
Assume a script is called from cron or from a web service, but only
one instance can be run at a time. With B<sem> and B<--shebang-wrap>
the script can be made to wait for other instances to finish. Here in
B<bash>:
#!/usr/bin/sem --shebang-wrap -u --id $0 --fg /bin/bash
echo This will run
sleep 5
echo exclusively
Here B<perl>:
#!/usr/bin/sem --shebang-wrap -u --id $0 --fg /usr/bin/perl
print "This will run ";
sleep 5;
print "exclusively\n";
Here B<python>:
#!/usr/local/bin/sem --shebang-wrap -u --id $0 --fg /usr/bin/python
import time
print "This will run ";
time.sleep(5)
print "exclusively";
=head1 EXAMPLE: Start editor with filenames from stdin (standard input) =head1 EXAMPLE: Start editor with filenames from stdin (standard input)
You can use GNU B<parallel> to start interactive programs like emacs or vi: You can use GNU B<parallel> to start interactive programs like emacs or vi: