Reputation: 65
I built a cron scheduler to run every 5 seconds just to test if it works.
It is working perfectly but how can I stop it? It is running even if I stop the server.
Trigger t1 = TriggerBuilder.newTrigger()
.withIdentity("ReminderSchedulerTrigger", "group1")
.withSchedule(
CronScheduleBuilder.cronSchedule("0/5 * * * * ?")
.inTimeZone(TimeZone.getTimeZone("Asia/Kolkata"))
)
.build();
Scheduler sc = StdSchedulerFactory.getDefaultScheduler();
sc.start();
sc.scheduleJob(job, t1);
I am using Ubuntu.
Upvotes: 0
Views: 1344
Reputation: 12803
Firstly, use below command to grep your project jar file
user@user:~$ ps aux | grep YourProject.jar
Then you will see something like this
user@user:~$ ps aux | grep xxx.jar
user 7438 40.1 3.3 4493040 271968 pts/7 Tl 11:06 0:10 java -jar xxx.jar
use command kill -9
to kill the process
user@user:~$ kill -9 7438
Upvotes: 0
Reputation: 494
On unix/linux:
On a command prompt type
ps -ef | grep jar-file-name
This will list the process details of your running jar. The second column of the result is the process id. For example the process id of the following line is 2571
501 2571 1 0 11Dec17 ?? 0:00.81 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres
You can then kill the process with the following command
kill -9 2571
Upvotes: 1