Calling a console script from java


Interested in true-way of calling scripts from a console Java.

Let's have script which need to pull. Say once per minute multiplied by the number of clients taken from the database, followed by very large responses with a delay.

Method Runtime.exec() will each call to create a systemic process that seems to me a little frightening if customers will be about 1000.

How competently to organize?
October 8th 19 at 00:53
3 answers
October 8th 19 at 00:55
And how are You going to run shell script without starting a new process?

You can write scripts in Groovy, then you can run without creating a new process
And how are You going to run shell script without starting a new process?

Yes, you don't know. It is one thing to run one or two or 10 processes, the other to poytapelit them in a while loop i++<1000.

At the expense of groovy, I thought, but the idea of what I want to run curl -o /dev/null -s-w "%{timetotal}" processing " awk " om something else that IMHO legavenue in the form of a script for that in groovy, what in java I have a bunch of stuff around to write to replicate this functionality. - javier.Swift commented on October 8th 19 at 00:58
You will not be able to run a shell script without launching a shell, i.e. another process.
As for functionality, in Groovy there is a lot to handle regular expressions and text. In the extreme case is the language of Sleep, which can also be run from Java, and which contains the capabilities of Perl for text processing. In any case, if you need to run many scripts, that run was scripts from Java, will process the script - vesta.Mann28 commented on October 8th 19 at 01:01
October 8th 19 at 00:57
In unix, start a new shell script (if the shell script) takes a fraction of a second (more tell the time command), which is comparable small in comparison with the frequency of launch. Nothing wrong with creating a new process.

But if it is a java program, its time initialisatie can be significant. Such a program is better not to restart often.

But if you want to touch the basics of the Jedi arts: make a daemon that will run, do the share work and cover for a minute, and your Java code in a minute to kick it message to the socket, and to revive and restart when it freezes/crashes.
Also, if processors, you can make a few sarkerov and script-superviser tracking them and distribute work. - javier.Swift commented on October 8th 19 at 01:00
There is some idea — there is a java application that manages the input, it lives separately, can be drained somewhere to the input frequency. Next you need to do the job that directly to execute periodically. For example, as I wrote — it curl. It can either theimplementing in Java, which will require substantial efforts both to implement and, IMHO, for the cost of implementation. And you can run it as a shell script, that seems to me more optimal. Now we have to figure out how to more effectively organize the transmission of the input data, the periodic execution of jobs and obtain results based on the conditions described in the question.

About the Jedi way with the demon — thank you, you have to look in that direction. But I feel that there must be a lot of difficulties has been written on shell, so that the frequency was correct... - vesta.Mann28 commented on October 8th 19 at 01:03
October 8th 19 at 00:59
In addition to the above. Ie everything is correct, run the script without launching the shell, is obviously impossible)
Hmm, so raise one process and pull it all the time, giving him the script. Or take the startup script out in the native environment in any way (a demon, as said above, or securerom or something like that).

Find more questions by tags JavaLinux