How to ran Java Jar file in AWS EC2 server.
I have tried -
nohup java -jar myfilename.jar > output.log &
With the above approach, I will store the logs in output.log file. I want to rotate it after 150 MB completed, Without stopping the application.
Also tried using PM2 -
Create process.json
{
"apps":[
{
"name": "my-backend-api",
"cwd":".",
"script":"/usr/bin/java",
"args":[
"-jar",
"/home/ubuntu/my-backend/target/my-api-0.0.1-SNAPSHOT.jar"
],
"watch":[
"/home/ubuntu/my-backend/target/my-api-0.0.1-SNAPSHOT.jar"
],
"node_args":[],
"log_date_format":"YYYY-MM-DD HH:mm Z",
"exec_interpreter":"",
"exec_mode":"fork"
}
]
}
pm2 start process.json
Does not seems to be working, each and every time, its restart the application. I don't want to do that.
Any help here ? Would be appreciated. Thank you in advanced