I want to execute my program at 13:00 every day for example
this is my method that I want run in this time>
I hope the experts will write the solution
And, if possible, converted to Windows Service
In order to make the server take a backup at 13:00 every day:
public static void backup() throws IOException{
try{
String date = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
String path="G:/DataBaseBackup/doctor_" + date + ".sql";
String user="root";
String password="12345";
String db="doctor";
Process runtimeProcess;
String exeutedrun="\"C:/Program Files/MySQL/MySQL Server 5.7/bin/mysqldump.exe\" -u " + user + " -p" + password + " --routines --events --add-drop-database -B " + db + " -r " + path;
runtimeProcess=Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", exeutedrun });
int processComplete = runtimeProcess.waitFor();
System.out.println(path);
if (processComplete == 0) {
System.out.println("Data Base is Backup !!");
error.write("Data Base is Backup in path : "+path);
} else {
System.out.println("Data Base is not Backup !!");
error.write("Data Base is not Backup : ");
}
}catch(Exception e){
error.Exption(e);
System.exit(1);
}
}