Execution of a client program in the background every certain period of time

-2

I need to make a client program in java so that I send "X" information to a database, every few seconds (1-3 seconds) and it is running second time since the system starts up until it shuts down. I do not know how I can make several lines of code run every "X" time without user interaction. Thanks

    
asked by CarlosMrt 25.09.2018 в 14:59
source

2 answers

0

I recommend that you use the programmed tasks tool of your Operating System, for example cron in Linux, and schedule a task that executes your client program java every minute or more, I do not know if it can be done every 3 seconds. On the other hand if you need the java client to run every 3 seconds, then put a Thread.sleep (3000). Slds.

    
answered by 25.09.2018 в 16:16
0

You can create that program that has a cron without having to use the programmed tasks of your Operating System, I have made an application that exclusively serves as cron and once a day make a request to an API and save that data in a database. Use this library: link

    
answered by 26.09.2018 в 10:18