1TS(1)                       General Commands Manual                      TS(1)
2
3
4

NAME

6       ts - task spooler. A simple unix batch system
7

SYNOPSIS

9       ts [actions] [options] [command...]
10
11       Actions: [-KClhV] [-t [id]] [-c [id]] [-p [id]] [-o [id]] [-s [id]] [-r
12       [id]] [-w [id]] [-k [id]] [-u [id]] [-i [id]] [-U <id-id>] [-S [num]]
13
14       Options: [-nfgmd] [-L <label>] [-D <id>]
15
16

DESCRIPTION

18       ts will run by default a per user unix task queue.  The  user  can  add
19       commands  to the queue, watch that queue at any moment, and look at the
20       task results (actually, standard output and exit error).
21

SIMPLE USE

23       Calling ts with a command will add that command to the queue, and call‐
24       ing it without commands or parameters will show the task list.
25

COMMAND OPTIONS

27       When adding a job to ts, we can specify how it will be run and how will
28       the results be collected:
29
30       -n     Do not store the standard output/error in a file  at  $TMPDIR  -
31              let  it use the file descriptors decided by the calling process.
32              If it is not used, the jobid for the new task will  be  outputed
33              to stdout.
34
35       -g     Pass the output through gzip (only if -n ). Note that the output
36              files will not have a .gz extension.
37
38       -f     Don not put the task into background. Wait  the  queue  and  the
39              command  run  without getting detached of the terminal. The exit
40              code will be that of the command, and if used together with  -n,
41              no result will be stored in the queue.
42
43       -m     Mail  the  results  of  the  command  (output  and exit code) to
44              $TS_MAILTO , or to the $USER using /usr/sbin/sendmail.  Look  at
45              ENVIRONMENT.
46
47       -L <label>
48              Add  a  label to the task, which will appear next to its command
49              when listing the queue. It makes more comfortable distinguishing
50              similar commands with different goals.
51
52       -d     Run the command only if the command before finished well (error‐
53              level = 0). This new task enqueued depends on the result of  the
54              previous  command.  If  the task is not run, it is considered as
55              failed for further dependencies.
56
57       -D <id>
58              Run the command only if  the  job  of  given  id  finished  well
59              (errorlevel  =  0). This new task enqueued depends on the result
60              of the previous command. If the task is not run, it  is  consid‐
61              ered  as failed for further dependencies.  If the server doesn't
62              have the job id in its list, it will be considered as if the job
63              failed.
64
65       -B     In  the case the queue is full (due to TS_MAXCONN or system lim‐
66              its), by default ts will block the enqueuing command. Using  -B,
67              if  the queue is full it will exit returning the value 2 instead
68              of blocking.
69
70       -E     Keep two different output  files  for  the  command  stdout  and
71              stderr.  stdout  goes  to the file announced by ts (look at -o),
72              and stderr goes to the stdout file with an additional ".e".  For
73              example,  /tmp/ts-out.SKsDw8 and /tmp/ts-out.SKsDw8.e.  Only the
74              stdout file gets created with  mkstemp,  ensuring  it  does  not
75              overwrite any other; the ".e" will be overwritten if it existed.
76
77       -N <num>
78              Run  the  command only if there are num slots free in the queue.
79              Without it, the job will run if there  is  one  slot  free.  For
80              example,  if  you  use the queue to feed cpu cores, and you know
81              that a job will take two cores, with -N  you  can  let  ts  know
82              that.
83

ACTIONS

85       Instead  of  giving  a new command, we can use the parameters for other
86       purposes:
87
88       -K     Kill the ts server for the calling client. This will remove  the
89              unix  socket and all the ts processes related to the queue. This
90              will not kill the command being run at that time.
91
92              It is not reliable to think that ts  -K  will  finish  when  the
93              server is really killed. By now it is a race condition.
94
95       -C     Clear the results of finished jobs from the queue.
96
97       -l     Show  the  list  of jobs - to be run, running and finished - for
98              the current queue.  This is  the  default  behaviour  if  ts  is
99              called without options.
100
101       -t [id]
102              Show  the last ten lines of the output file of the named job, or
103              the last running/run if not specified. If the job is still  run‐
104              ning,  it  will  keep on showing the additional output until the
105              job finishes. On exit, it returns the errorlevel of the job,  as
106              in -c.
107
108       -c [id]
109              Run the system's cat to the output file of the named job, or the
110              last running/run if not specified. It will block until  all  the
111              output  can  be  sent to standard output, and will exit with the
112              job errorlevel as in -c.
113
114       -p [id]
115              Show the pid of the named job, or the last  running/run  if  not
116              specified.
117
118       -o [id]
119              Show  the  output  file  name of the named job, or the last run‐
120              ning/run if not specified.
121
122       -s [id]
123              Show the job state of the named job, or the last in the queue.
124
125       -r [id]
126              Remove the named job, or the last in the queue.
127
128       -w [id]
129              Wait for the named job, or for the last in the queue.
130
131       -k [id]
132              Kill the process group of the named job (SIGTERM), or  the  last
133              running/run  job  if  not specified.  Equivalent to kill -- -`ts
134              -p`
135
136       -u [id]
137              Make the named job (or the last in  the  queue)  urgent  -  this
138              means that it goes forward in the queue so it can run as soon as
139              possible.
140
141       -i [id]
142              Show information about the named job (or the last run). It  will
143              show  the command line, some times related to the task, and also
144              any information resulting from TS_ENV (Look at ENVIRONMENT).
145
146       -U <id-id>
147              Interchange the queue positions of the named jobs (separated  by
148              a hyphen and no spaces).
149
150       -h     Show help on standard output.
151
152       -V     Show the program version.
153

MULTI-SLOT

155       ts  by default offers a queue where each job runs only after the previ‐
156       ous finished.  Nevertheless, you can change the maximum number of  jobs
157       running  at  once  with the -S [num] parameter. We call that number the
158       amount of slots. You can also set the initial number of jobs  with  the
159       environment  variable  TS_SLOTS .  When increasing this setting, queued
160       waiting jobs will be run at once until reaching the maximum  set.  When
161       decreasing this setting, no other job will be run until it can meet the
162       amount of running jobs set.   When using an  amount  of  slots  greater
163       than  1,  the action of some commands may change a bit. For example, -t
164       without jobid will tail the first job running, and -d will try  to  set
165       the dependency with the last job added.
166
167       -S [num]
168              Set  the  maximum  amount  of running jobs at once. If you don't
169              specify num it will return the maximum amount  of  running  jobs
170              set.
171

ENVIRONMENT

173       TS_MAXFINISHED
174              Limit the number of job results (finished tasks) you want in the
175              queue. Use this option if you are tired of -C.
176
177       TS_MAXCONN
178              The maximum number of ts server  connections  to  clients.  This
179              will make the ts clients block until connections are freed. This
180              helps, for example, on systems with a  limited  number  of  pro‐
181              cesses,  because  each  job  waiting  in  the queue remains as a
182              process. This variable has to be set at server start, and cannot
183              be modified later.
184
185       TS_ONFINISH
186              If the variable exists pointing to an executable, it will be run
187              by the client after the queued job. It uses execlp, so  PATH  is
188              used  if  there are no slashes in the variable content. The exe‐
189              cutable is run  with  four  parameters:  jobid  errorlevel  out‐
190              put_filename and command.
191
192       TMPDIR As  the  program  output  and  the unix socket are thought to be
193              stored in a temporary directory, TMPDIR will be used if defined,
194              or /tmp otherwise.
195
196       TS_SOCKET
197              Each queue has a related unix socket. You can specify the socket
198              path with this environment variable. This way, you  can  have  a
199              queue  for  your heavy disk operations, another for heavy use of
200              ram., and have a simple script/alias wrapper over ts  for  those
201              special   queues.   If   it   is   not  specified,  it  will  be
202              $TMPDIR/socket-ts.[uid].
203
204       TS_SLOTS
205              Set the number of slots at the start of the server,  similar  to
206              -S,  but the contents of the variable are read only when running
207              the first instance of ts.
208
209       TS_MAILTO
210              Send the letters with job results to the  address  specified  in
211              this  variable.   Otherwise,  they  are  sent to $USER or if not
212              defined, nobody.  The system /usr/sbin/sendmail is used. The job
213              outputs  are not sent as an attachment, so understand the conse‐
214              quences if you use the -gm flags together.
215
216       USER   As seen above, it is used for the mail destination if  TS_MAILTO
217              is not specified.
218
219       TS_SAVELIST
220              If  it  is  defined when starting the queue server (probably the
221              first ts command run), on SIGTERM the queue status will be saved
222              to  the file pointed by this environment variable - for example,
223              at system shutdown.
224
225       TS_ENV This has a command to be run at enqueue  time  through  /bin/sh.
226              The  output  of  the command will be readable through the option
227              -i. You can use a command which shows relevant  environment  for
228              the     command    run.     For    example,    you    may    use
229              TS_ENV='pwd;set;mount'.
230

FILES

232       /tmp/ts.error
233              if ts finds any internal  problem,  you  should  find  an  error
234              report there.  Please send this to the author as part of the bug
235              report.
236
237

BUGS

239       ts expects a simple command line. It does not start a shell parser.  If
240       you  want  to  run  complex  shell  commands,  you may want to run them
241       through sh -c 'commands...'  Also,  remember  that  stdin/stdout/stderr
242       will be detached, so do not use your shell's redirection operators when
243       you put a job into background.  You can use them inside the  sh  -c  in
244       order to set redirections to the command run.
245
246       If  an  internal  problem  is found in runtime, a file /tmp/ts.error is
247       created, which you can submit to the developer in order to fix the bug.
248
249

SEE ALSO

251       at(1)
252

AUTHOR

254       Lluis Batlle i Rossell
255

NOTES

257       This page describes ts as in version 1.0. Other  versions  may  differ.
258       The  file  TRICKS found in the distribution package can show some ideas
259       on special uses of ts.
260
261
262
263Task Spooler 1.0                    2016-03                              TS(1)
Impressum