0

So I run the bash script below:

#!/bin/bash
cd /data/www/usr/rzzw/todo/
for i in *; do
    endpoint=$(less $i | sed -rn 's/(.*\|endpoint - )(.*)/\2/p')
    nohup java -jar /data/www/usr/rzzw/sum/file.jar /data/www/usr/rzzw/sum/config.properties $endpoint 1>"../done/$i-out" 2>"../done/err/$i-err" &
done

It works fine, creates logs and executes jar file X times. Thats exactly what i wanted. The jar file starts getting informations about SPARQL endpoint.

But at the beginning this file has to do a complicated SPARQL select which sametimes may take a lot of time. During waiting for a response "something" kills these processes. I was expecting that nohup is gonna take care about background process &.

STDERR:

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)

This error happens only when commands are being done by script. When I try it in Linux terminal by myself there are no errors.

Example of working command:

nohup java -jar /data/www/usr/rzzw/sum/file.jar /data/www/usr/rzzw/sum/config.properties data.archiveshub.ac.uk/sparql 1>out 2>err &

Is there any other solution for running -jar file multiple times or can somehow this bash script wait until it responses?

I didnt create this -jar file and everything that happens during its execution is written just in command line.

dzb
  • 21
  • 7
  • Yes I mean Linux terminal, sorry about that. Command: nohup java -jar /data/www/usr/rzzw/sum/file.jar /data/www/usr/rzzw/sum/config.properties http://data.archiveshub.ac.uk/sparql 1>out 2>err & – dzb Jan 08 '19 at 21:57
  • The post is edited, hope it's clear now :) – dzb Jan 09 '19 at 06:46
  • Try adding `wait` to have processes finish: https://stackoverflow.com/q/14254118/1422451 – Parfait Jan 09 '19 at 13:15

0 Answers0