Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nfaguirrec/sjobq
Browse files Browse the repository at this point in the history
  • Loading branch information
nfaguirrec committed Dec 10, 2015
2 parents b1fd7e7 + fa77115 commit 959af6b
Show file tree
Hide file tree
Showing 2 changed files with 213 additions and 1 deletion.
212 changes: 212 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
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.

### INSTALLING
```
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/
```

### DEMON STARTUP
```
$ sjobq.d 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 !,$,#.

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

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

```
$ sjobq.stat
+-------------+
| Current job |
+-------------+
pid = 29406
command = sleep 30s
dir = ~/Downloads
time spent = 00-00:00:09
pids = 29406
tree =
sleep(29406)
+-------+
| 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
```
$ sjobq.push sleep 1h
id = 4
command = sleep 1h
dir = ~/Downloads
$ sjobq.push sleep 2h
id = 5
command = sleep 1h
dir = ~/Downloads
$ sjobq.push sleep 3h
id = 6
command = sleep 1h
dir = ~/Downloads
$ 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
+-------+------------------+----------
+-------------+
| 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.
```
$ sjobq.del 6
Job with id=6 has been deleted !!
$ 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
+-------+------------------+----------
+-------------+
| 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
+-------------+------------------+----------
```
Also it is possible to delete the running job by using the identifier "current".
```
$ sjobq.del current
Job with id=current has been deleted !!
$ sjobq.stat
+-------------+
| Current job |
+-------------+
pid = 31544
command = sleep 2h
dir = ~/Downloads
time spent = 00-00:00:05
pids = 31544
tree =
sleep(31544)
+-------------+
| 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
| 00-00:02:57 | ~/Downloads | sleep 1h
+-------------+------------------+----------
```
### DAEMON SHUTDOWN
```
$ sjobq.d stop
==============================
SJobQ daemon has been stopped
==============================
```

### Authors and Contributors
Néstor F. Aguirre (@nfaguirrec) 2010-2015
2 changes: 1 addition & 1 deletion sjobq.d
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function update()
echo "echo \$! > $CURRENT_JOB_HOME/pid" >> .tmp2156456

chmod +x .tmp2156456
./.tmp2156456
bash ./.tmp2156456
rm .tmp2156456

rm -f $DATA_DIR/$IDL.bid
Expand Down

0 comments on commit 959af6b

Please sign in to comment.