TRICKS
author viric@llimona
Sat, 09 Feb 2008 11:56:03 +0100
changeset 196 bca29e2a1a86
parent 183 95d49e8a8cec
child 269 56061026d168
permissions -rw-r--r--
Fixing a bug related to a message on -t on last job, when it was skipped.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
     1
System wide queue
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
     2
-------------------------
79
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
     3
You can set the $TS_SOCKET variable to the same name path for all your
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
     4
'ts' processes, and then
57
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
     5
they'll use the same socket for intercommunication. This means - single queue.
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
     6
You should be certain that any 'ts' can read/write to that socket, using
79
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
     7
chmod.
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
     8
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
     9
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
    10
A queue for each resource
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
    11
-------------------------
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
    12
You can use $TS_SOCKET and aliases/scripts for having different queues for
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
    13
different resources. For instance, using bash:
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
    14
alias tsdisk='TS_SOCKET=/tmp/socket.disk ts'
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
    15
alias tsram='TS_SOCKET=/tmp/socket.ram ts'
f99c2548fac4 Updated tricks.
viric@llimona
parents: 57
diff changeset
    16
alias tsnet='TS_SOCKET=/tmp/socket.net ts'
57
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
    17
165
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    18
You can also create shell scripts like this:
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    19
<< FILE ts2
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    20
#!/bin/sh
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    21
export TS_SOCKET=/tmp/socket-ts2.$USER
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    22
ts "$@"
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    23
>> END OF FILE ts2
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    24
57
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
    25
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
    26
Be notified of a task finished
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
    27
-------------------------
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
    28
In X windows, inside bash, after submitting the task, I use:
ab48625beecb Added a compilation of tricks.
lbatlle@npdl268.bpo.hp.com
parents:
diff changeset
    29
$ ( ts -w ; xmessage Finished! ) &
165
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    30
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    31
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    32
Dependant commands
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    33
-------------------------
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    34
If you want your command to be run only if the job before went well,
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    35
use the parameter -d.
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    36
If you want a job to be executed depending on the result of any
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    37
previous job run, you can enqueue this way:
7b914d4003c2 Fixing licenses in some files, and updating some documents.
viric@mandarina
parents: 79
diff changeset
    38
$ ts sh -c 'ts -w JOBID && NEWCOMMAND'
183
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    39
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    40
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    41
Killing process groups
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    42
-------------------------
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    43
ts creates a new session for the job, so the pid of the command run can be
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    44
used as the process group id for the command and its childs. So, you can use
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    45
something like:
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    46
$ kill -- -`ts -p`
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    47
in order to kill the job started and all its childs. I find it useful when
95d49e8a8cec Updating 'help' and some other related files to 0.5
viric@llimona
parents: 165
diff changeset
    48
killing 'make's.