Skip to content

Commit

Permalink
The code has been reorganized and several bugs have been fixed. There…
Browse files Browse the repository at this point in the history
… is an important improvement with the inclusion of the command sjobq.sort, now the jobs in the queue may be sorted.
  • Loading branch information
nfaguirrec committed Jul 20, 2016
1 parent 959af6b commit 72ff187
Show file tree
Hide file tree
Showing 7 changed files with 625 additions and 354 deletions.
175 changes: 143 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,64 @@
SJobQ is a very simple queue system written in Bourne shell for managing serial executions running in a local form on only one machine. In some situations is important to let that a set of jobs running one by one without human supervision. This allow you to exploit the computing resources available on your machine, in order to keep the machine working all the time. The principal problem is that the available queue systems are a bit complicated to install or simply you need to be root to install them and you don't have those permissions. SJobQ is the solution, because, you don't need to be root and in order to install it you only need download three files and go !, you can begin to work.
SJobQ is a very simple queue system written in Bourne shell. It manages serial executions that run in a local form. The aim is to keep the computer working all the time, in order to exploit as much as possible your available computing resources. Regarding standard available programs to manage queues, very often they are a bit complicated to install and/or to configure, or simply you need administrative privileges to install them and you have no those permissions. For these cases, SJobQ is the solution, because in order to install it, you only need to download six files and that is all !. You can start to work.

### INSTALLING
Download the .zip file from this page and extract the files,
```
DOWNLOAD THE .tar.gz FILE FROM THIS PAGE AND TYPE NEXT COMMANDS
$ tar xvfz nfaguirrec-sjobq-xxxxxxx.tar.gz
nfaguirrec-sjobq-xxxxxxx/
nfaguirrec-sjobq-xxxxxxx/sjobq.d
nfaguirrec-sjobq-xxxxxxx/sjobq.del
nfaguirrec-sjobq-xxxxxxx/sjobq.push
nfaguirrec-sjobq-xxxxxxx/sjobq.stat
$ ls nfaguirrec-sjobq-xxxxxxx
sjobq.d sjobq.del sjobq.push sjobq.stat
$ cp nfaguirrec-sjobq-xxxxxxx/* $HOME/bin/
$ unzip sjobq-master.zip
Archive: sjobq-master.zip
1dde49967385f2ba76d34a1af52f70df9d4174f9
creating: sjobq-master/
inflating: sjobq-master/README.md
inflating: sjobq-master/sjobq.d
inflating: sjobq-master/sjobq.del
inflating: sjobq-master/sjobq.push
inflating: sjobq-master/sjobq.stat
$ mv sjobq-master/ sjobq
```
or clone the repository using git
```
$ git clone https://github.com/nfaguirrec/sjobq.git
```
This should be the content of the sjobq directory if previous steps were successful:
```
$ ls sjobq
sjobq.client sjobq.daemon sjobq.del sjobq.sort sjobq.push sjobq.stat
```
Finally, to install the program, you simply have to copy the files in a directory included in the PATH system variable, as for example bin in your home directory:
```
$ cp sjobq/* $HOME/bin/
```

### DEMON STARTUP
```
$ sjobq.d start
$ sjobq.daemon start
==============================
SJobQ daemon has been started
==============================
```

### PUTTING JOBS IN THE QUEUE
To put jobs into queue, use the command sjob.queue before its statement. Its important to point out you have to use the character \ if you are going to use special bash characters like !,$,#.
To put jobs into queue, use the command sjob.queue before its statement.
Its important to point out you have to use the character \ if you are going to use special bash characters like !,$,#.

```
$ sjobq.push sleep 30s
id = 1
command = sleep 30s
dir = /home/nestor/Downloads
dir = ~/Downloads
$ sjobq.push echo \"Hola\"
id = 2
command = echo "Hola"
dir = /home/nestor/Downloads
dir = ~/Downloads
$ sjobq.push find /etc/ -name \"\*.conf\" \> output \; sleep 30
id = 3
command = find /etc/ -name "*.conf" > output ; sleep 30
dir = /home/nestor/Downloads
dir = ~/Downloads
```

### CHECKING JOBS STATUS
The command sjobq.stat will show the jobs which are running, queued and finished.
The command sjobq.stat will show the jobs which they are running, queued and those what already have finished.

```
$ sjobq.stat
Expand All @@ -63,30 +76,30 @@ tree =
+-------+
| QUEUE |
+-------+------------------+----------
+-------+------------------+--------------------
| id | directory | command
| | |
| 2 | ~/Downloads | echo "Hola"
| 3 | ~/Downloads | find /etc/ -name "*.conf" > output ; sleep 30
+-------+------------------+----------
+-------+------------------+--------------------
```
after 2 minutes ...
```
$ sjobq.stat
+-------------+
| HISTORY |
+-------------+------------------+----------
+-------------+------------------+--------------------
| time spent | directory | command
| | |
| 00-00:00:30 | ~/Downloads | sleep 30s
| 00-00:00:04 | ~/Downloads | echo "Hola"
| 00-00:00:31 | ~/Downloads | find /etc/ -name "*.conf" > output ; sleep 30
+-------------+------------------+----------
+-------------+------------------+--------------------
```

### DELETING JOBS
Imagine that you put the following commands in the queue
### DELETING AND SORTING JOBS
Let's consider you put the following commands in the queue
```
$ sjobq.push sleep 1h
id = 4
Expand All @@ -103,6 +116,11 @@ id = 6
command = sleep 1h
dir = ~/Downloads
$ sjobq.push sleep 4h
id = 6
command = sleep 1h
dir = ~/Downloads
$ sjobq.stat
+-------------+
| Current job |
Expand All @@ -118,24 +136,103 @@ tree =
+-------+
| QUEUE |
+-------+------------------+----------
+-------+------------------+--------------------
| id | directory | command
| | |
| 5 | ~/Downloads | sleep 2h
| 6 | ~/Downloads | sleep 3h
+-------+------------------+----------
| 7 | ~/Downloads | sleep 4h
+-------+------------------+--------------------
+-------------+
| HISTORY |
+-------------+------------------+----------
+-------------+------------------+--------------------
| time spent | directory | command
| | |
| 00-00:00:30 | ~/Downloads | sleep 30s
| 00-00:00:04 | ~/Downloads | echo "Hola"
| 00-00:00:31 | ~/Downloads | find /etc/ -name "*.conf" > output ; sleep 30
+-------------+------------------+----------
+-------------+------------------+--------------------
```
You can sort the queued jobs by using its identifier (id). The id is provided in the output of the sqjob.stat command.
For example:

Move the specified jobID to the top of the queue:
```
$ sjobq.sort top 7
$ sjobq.stat
+-------------+
| Current job |
+-------------+
pid = 30778
command = sleep 1h
dir = ~/Downloads
time spent = 00-00:00:29
pids = 30778
tree =
sleep(30778)
+-------+
| QUEUE |
+-------+------------------+--------------------
| id | directory | command
| | |
| 5 | ~/Downloads | sleep 4h
| 6 | ~/Downloads | sleep 3h
| 7 | ~/Downloads | sleep 2h
+-------+------------------+--------------------
+-------------+
| HISTORY |
+-------------+------------------+--------------------
| time spent | directory | command
| | |
| 00-00:00:30 | ~/Downloads | sleep 30s
| 00-00:00:04 | ~/Downloads | echo "Hola"
| 00-00:00:31 | ~/Downloads | find /etc/ -name "*.conf" > output ; sleep 30
+-------------+------------------+--------------------
```

or swap two jobs in the queue:
```
$ sjobq.sort swap 5 7
$ sjobq.stat
+-------------+
| Current job |
+-------------+
pid = 30778
command = sleep 1h
dir = ~/Downloads
time spent = 00-00:00:29
pids = 30778
tree =
sleep(30778)
+-------+
| QUEUE |
+-------+------------------+--------------------
| id | directory | command
| | |
| 5 | ~/Downloads | sleep 2h
| 6 | ~/Downloads | sleep 3h
| 7 | ~/Downloads | sleep 4h
+-------+------------------+--------------------
+-------------+
| HISTORY |
+-------------+------------------+--------------------
| time spent | directory | command
| | |
| 00-00:00:30 | ~/Downloads | sleep 30s
| 00-00:00:04 | ~/Downloads | echo "Hola"
| 00-00:00:31 | ~/Downloads | find /etc/ -name "*.conf" > output ; sleep 30
+-------------+------------------+--------------------
```
You can delete a queued job by using its identifier (id). The id is provided in the output of the sqjob.stat command.
For more options, please take a look to the available parameters of the sjobq.sort command: raise,lower,top,bottom and swap.

You can also delete a queued job by using its identifier (id).
```
$ sjobq.del 6
Job with id=6 has been deleted !!
Expand Down Expand Up @@ -171,7 +268,8 @@ tree =
| 00-00:00:31 | ~/Downloads | find /etc/ -name "*.conf" > output ; sleep 30
+-------------+------------------+----------
```
Also it is possible to delete the running job by using the identifier "current".

It is also possible to delete the running job by using the identifier "current".
```
$ sjobq.del current
Job with id=current has been deleted !!
Expand Down Expand Up @@ -200,13 +298,26 @@ tree =
| 00-00:02:57 | ~/Downloads | sleep 1h
+-------------+------------------+----------
```

### DAEMON SHUTDOWN
If you want simply to stop the daemon:
```
$ sjobq.d stop
==============================
SJobQ daemon has been stopped
==============================
```
Note that the current job will be still running after this. Additionally, those enqueued jobs will be recovered when daemon is restarted.

If you want to stop the daemon and clean all configuration data:
```
$ sjobq.d stop clean
Job with id=current has been deleted !!
The SjobQ configuration has been cleaned up successfully !!
==============================
SJobQ daemon has been stopped
==============================
```

### Authors and Contributors
Néstor F. Aguirre (@nfaguirrec) 2010-2015
Néstor F. Aguirre (@nfaguirrec) 2010-2016
Loading

0 comments on commit 72ff187

Please sign in to comment.