Process Management – Simple Queuing System

processprocess-managementscheduling

Given a commodity PC, we would like to use it to execute some tasks in the background round the clock.

Basically, we would like to have commands like:

add-task *insert command here*
list-tasks
remove-task(s)

The added tasks should simply be put in a queue and executed one after another in the background (keeping running after logout of the shell).

Is there any simple script/program that does this?

Best Answer

There's a standard batch command that does more or less what you're after. More precisely, batch executes the jobs when the system load is not too high, one at a time (so it doesn't do any parallelization). The batch command is part of the at package.

echo 'command1 --foo=bar' | batch      
echo 'command2 "$(wibble)"' | batch
at -q b -l              # on many OSes, a slightly shorter synonym is: atq -q b
at -q b -r 1234         # Unschedule a pending task (atq gives the task ID)
Related Question