Reputation: 3186
I use putty for taking linux machine terminal from my windows machine and run a java program.
Java Class
try {
Timer t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
logger.info(new Date()+"...");
i=i+1;
}
}, new Date(), 3000);
if(i==50){
t.cancel();
}
} catch (Exception e) {
e.printStackTrace();
}
This program write a line in every 3 second. If I close the putty it stop running. Program become end, it not writing any more lines in the logger file.
How can I run java program in the backend or even in running state after closing putty terminal ?
Upvotes: 1
Views: 3340
Reputation: 449
You can look into using the screen
utility on linux which continues to run after after you logout of your session.
https://www.linode.com/docs/networking/ssh/using-gnu-screen-to-manage-persistent-terminal-sessions
Upvotes: 1