TSP(1)
๐ TSP(1) ๐
okay bestie, so this is the manual for tsp, from the General Commands Manual section. yes we're doing manpage reading, it's giving study date energy, and honestly? you're gonna eat this up. ๐
โจ NAME โจ
tsp โ task spooler. A simple unix batch system. ๐ซถ
๐ SYNOPSIS ๐
tsp [actions] [options] [command...]
Actions: [-KClhV] [-t [id]] [-c [id]] [-p [id]] [-o [id]] [-s [id]] [-r
[id]] [-w [id]] [-k [id]] [-u [id]] [-i [id]] [-U <id-id>] [-S [num]]
Options: [-nfgmd] [-L <label>] [-D <id>]
like, that's the whole vibe of how you talk to it ๐
๐ฆ DESCRIPTION ๐ฆ
so by default, tsp runs a per user unix task queue. that's it, that's the whole personality. you can:
- add commands to the queue โจ
- watch that queue whenever you want, at any moment, no cap ๐
- look at the task results (which is literally the standard output and the exit error) ๐
๐ SIMPLE USE ๐
- call
tspwith a command โ that command gets added to the queue - call it without commands or parameters โ you get the task list
that's it. iconic. main character energy fr fr. ๐
๐ COMMAND OPTIONS ๐
when you're adding a job to ts, you get to pick how it runs and how the results get collected. obsessed with the customization tbh:
-nโ do not store the standard output/error in a file at$TMPDIR; let it use the file descriptors decided by the calling process instead. if you don't use this, the jobid for the new task gets output to stdout. ๐ซถ-gโ pass the output throughgzip(only if-n). heads up bestie: the output files will not have a.gzextension. sneaky!-fโ do not put the task into background. wait for the queue and the command to run without getting detached from the terminal. the exit code will be that of the command, and if you use it together with-n, no result will be stored in the queue. ๐ง-mโ mail the results of the command (output and exit code) to$TS_MAILTO, or to the$USERusing/usr/sbin/sendmail. look at ENVIRONMENT, i linked it below like a good bestie ๐-L <label>โ add a label to the task, and it'll show up next to its command when you list the queue. makes distinguishing similar commands with different goals way comfier. so cute. ๐ท๏ธ-dโ run the command only if the command before it finished well (errorlevel = 0). this new enqueued task depends on the result of the previous command. if the task is not run, it's considered as failed for further dependencies. ๐ญ-D <id>โ run the command only if the job of the given id finished well (errorlevel = 0). this new enqueued task depends on the result of the previous command. if the task is not run, it is considered as failed for further dependencies. and if the server doesn't have the job id in its list, it'll be considered as if the job failed. ๐-Bโ in the case the queue is full (due toTS_MAXCONNor system limits), by defaulttswill block the enqueuing command. with-B, if the queue is full it exits returning the value2instead of blocking. bye bestie ๐-Eโ keep two different output files for the command stdout and stderr. stdout goes to the file announced byts(look at-o), and stderr goes to the stdout file with an additional".e". for example,/tmp/ts-out.SKsDw8and/tmp/ts-out.SKsDw8.e. only the stdout file gets created withmkstemp, ensuring it doesn't overwrite any other; the".e"will be overwritten if it existed. ๐-N <num>โ run the command only if there arenumslots free in the queue. without it, the job will run if there's one slot free. like, if you use the queue to feed cpu cores and you know a job is gonna take two cores,-Nlets you telltsthat. so considerate. ๐ง
โญ ACTIONS โญ
instead of giving a new command, you can use the parameters for other purposes. multitasking queen:
-Kโ kill thetspserver for the calling client. this removes the unix socket and all thetspprocesses related to the queue. it will not kill the command being run at that time.
also, do not trust that tsp -K will finish when the server is really killed. by now it's a race condition. we're just living with it bestie ๐ญ
-Cโ clear the results of finished jobs from the queue. clean girl aesthetic ๐งผ-lโ show the list of jobs โ to be run, running, and finished โ for the current queue. this is the default behaviour iftspis called without options. the default! iconic.-t [id]โ show the last ten lines of the output file of the named job, or the last running/run one if you don't specify. if the job is still running, it keeps showing the additional output until the job finishes. on exit, it returns the errorlevel of the job, as in-c. ๐-c [id]โ run the system'scatto the output file of the named job, or the last running/run if not specified. it will block until all the output can be sent to standard output, and will exit with the job errorlevel as in-c. ๐-p [id]โ show the pid of the named job, or the last running/run if not specified. ๐-o [id]โ show the output file name of the named job, or the last running/run if not specified. ๐-s [id]โ show the job state of the named job, or the last in the queue. ๐ฆ-r [id]โ remove the named job, or the last in the queue. ๐๏ธ-w [id]โ wait for the named job, or for the last in the queue. โณ-k [id]โ kill the process group of the named job (SIGTERM), or the last running/run job if not specified. equivalent tokill -- -ts -p`` ๐-u [id]โ make the named job (or the last in the queue) urgent โ this means it goes forward in the queue so it can run as soon as possible. skip the line, princess treatment ๐-i [id]โ show information about the named job (or the last run). it'll show the command line, some times related to the task, and also any information resulting fromTS_ENV(look at ENVIRONMENT). ๐ต๏ธ-U <id-id>โ interchange the queue positions of the named jobs (separated by a hyphen and no spaces). ๐-hโ show help on standard output. ๐-Vโ show the program version. โจ
๐ธ MULTI-SLOT ๐ธ
okay so tsp by default gives you a queue where each job runs only after the previous one finished. but!! you can change the maximum number of jobs running at once with the -S [num] parameter. we call that number the amount of slots. you can also set the initial number of jobs with the environment variable TS_SLOTS. ๐ฅ
- when you increase this setting, queued waiting jobs will run at once until reaching the maximum set.
- when you decrease this setting, no other job will be run until it can meet the amount of running jobs set.
when you use an amount of slots greater than 1, the action of some commands may change a bit. for example, -t without a jobid will tail the first job running, and -d will try to set the dependency with the last job added. lowkey a whole different vibe at that point.
-S [num]โ set the maximum amount of running jobs at once. if you don't specifynum, it will return the maximum amount of running jobs set. ๐๏ธ
๐ง ENVIRONMENT ๐ง
TS_MAXFINISHEDโ limit the number of job results (finished tasks) you want in the queue. use this if you are tired of-C. we've all been there. ๐ฎโ๐จTS_MAXCONNโ the maximum number oftsserver connections to clients. this makes thetsclients block until connections are freed. it helps, for example, on systems with a limited number of processes, because each job waiting in the queue remains as a process. this variable has to be set at server start, and cannot be modified later. no takebacks. ๐ซTS_ONFINISHโ if the variable exists pointing to an executable, it will be run by the client after the queued job. it usesexeclp, soPATHis used if there are no slashes in the variable content. the executable is run with four parameters:jobiderrorleveloutput_filenameandcommand. ๐ฌTMPDIRโ as the program output and the unix socket are thought to be stored in a temporary directory,TMPDIRwill be used if defined, or/tmpotherwise. ๐๏ธTS_SOCKETโ each queue has a related unix socket. you can specify the socket path with this environment variable. this way, you can have a queue for your heavy disk operations, another for heavy use of ram., and have a simple script/alias wrapper overtsfor those special queues. if it's not specified, it will be$TMPDIR/socket-ts.[uid]. multiple queues = multiple personalities, slay ๐TS_SLOTSโ set the number of slots at the start of the server, similar to-S, but the contents of the variable are read only when running the first instance oftsp. ๐ฐTS_MAILTOโ send the letters with job results to the address specified in this variable. otherwise, they're sent to$USERor, if not defined,nobody. the system/usr/sbin/sendmailis used. the job outputs are not sent as an attachment, so understand the consequences if you use the-gmflags together. ๐ฌUSERโ as seen above, it's used for the mail destination ifTS_MAILTOisn't specified. ๐TS_SAVELISTโ if it's defined when starting the queue server (probably the firsttspcommand run), onSIGTERMthe queue status will be saved to the file pointed by this environment variable โ for example, at system shutdown. saving your progress, so responsible ๐พTS_ENVโ this has a command to be run at enqueue time through/bin/sh. the output of the command will be readable through the option-i. you can use a command which shows relevant environment for the command run. for example, you may useTS_ENV='pwd;set;mount'. โจ
๐ FILES ๐
/tmp/ts.errorโ iftspfinds any internal problem, you should find an error report there. please send this to the author as part of the bug report. ๐
๐ BUGS ๐
tsp expects a simple command line. it does not start a shell parser. if you want to run complex shell commands, you may want to run them through sh -c 'commands...'
also, remember that stdin/stdout/stderr will be detached, so do not use your shell's redirection operators when you put a job into background. you can use them inside the sh -c in order to set redirections to the command run. bestie i'm begging you ๐
if an internal problem is found in runtime, a file /tmp/ts.error is created, which you can submit to the developer in order to fix the bug. ๐ฎ
๐ SEE ALSO ๐
๐ AUTHOR ๐
Lluis Batlle i Rossell
๐ NOTES ๐
this page describes tsp as in version 1.0. other versions may differ. the file TRICKS found in the distribution package can show some ideas on special uses of tsp. go read it, i know you want to ๐ฆ
and that's the whole thing, bestie!! ๐ this page is describing Task Spooler 1.0.3, dated 2020-12 โ yes, vintage, yes still iconic, we stan a classic. now go queue something up and be the main character of your own batch system ๐โจ๐
๐ฆ where this page comes from
- ubuntu questing: task-spooler 1.0.3+dfsg1-2
- ubuntu resolute: task-spooler 1.0.3+dfsg1-2build1 ยท GPL-2.0-only
- ubuntu stonking: task-spooler 1.0.3+dfsg1-2build1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms