Question:
My system has the dental appointments part and I need to send an email to the client, in case his appointment is that day.
For example: Run an email auto-trigger always at midnight every day. This email trigger will check if you have appointments that day and if so will send the email.
How do I run this check with java?
Answer:
There are task scheduling frameworks, however to just run a script daily you can use much simpler solutions. Operating systems have a task scheduler: on linux there is cron
, on windows there is a Agendador de Tarefas
(less creative name, by the way).
Basically, you create a java program that, when executed, sends the emails with the queries, without worrying about the time. To schedule, you create a script like this:
@echo off
REM run the program
"C:\Program Files\Java\jdk1.7.0\bin\java.exe" -jar "C:\Users\User1 \Documents\project\emailConsulta.jar"
So, just create a task in Windows Task Scheduler accessed with Win+R > type "Taskschd.msc" > Enter. There, you can control which days of the week it will run, at what time, among other options.