Execute command in cmd once every hour

0

I've setup Minecraft with Dynmap and it works like it should. Though I would like it to run a specific command every hour.

I start the server by running a file called run.bat which looks like this

java -Xmx1024M -jar craftbukkit.jar -o true
PAUSE

This starts the server and the Dynmap plugin. I can then execute commands in the cmd window that opens to do different things.

The command that I want to execute every hour looks like this:

dynmap fullrender world and is executed in an already started program, is it possible to schedule a command in cmd so that it is executed once every hour?

Oskar Persson

Posted 2013-07-22T13:45:39.800

Reputation: 898

This information is available in a lot of places on the internet, and on this forum if you search. Using the terms you entered I found numerous resources that explain it. – Taegost – 2013-07-22T13:57:53.367

You won't be able to do this except from another plugin or a server wrapper. If you're on Windows, I made http://yams.in which now allows scheduling of any command directly into the console.

– Richard Benson – 2013-07-22T17:11:24.900

Answers

2

You can use the Windows Task Scheduler to schedule it. From the steps here: http://windows.microsoft.com/en-us/windows7/schedule-a-task

Open Task Scheduler by clicking the Start button Picture of the Start button, clicking Control Panel, clicking System and Security, clicking Administrative Tools, and then double-clicking Task Scheduler.‌ Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

Click the Action menu, and then click Create Basic Task.

Type a name for the task and an optional description, and then click Next.

Do one of the following:

To select a schedule based on the calendar, click Daily, Weekly, Monthly, or One time, click Next; specify the schedule you want to use, and then click Next.

To select a schedule based on common recurring events, click When the computer starts or When I log on, and then click Next.

To select a schedule based on specific events, click When a specific event is logged, click Next; specify the event log and other information using the drop-down lists, and then click Next.

To schedule a program to start automatically, click Start a program, and then click Next.

Click Browse to find the program you want to start, and then click Next.

Click Finish.

Taegost

Posted 2013-07-22T13:45:39.800

Reputation: 637

I know I can start a program from the task scheduler but I need to execute dynmap fullrender world in an already started program. – Oskar Persson – 2013-07-22T13:59:18.300

Your question wasn't clear at all on that point, you need to update your original question or you're going to get a lot of people giving you this same information. – Taegost – 2013-07-22T14:00:32.567

Updated my question – Oskar Persson – 2013-07-22T14:03:28.977

1

Try something like:

> for /L %i in (1,1,24) do timeout /T 3600 <command>

3600 represents a time in seconds.

60 × 60 = 3600s

The command for will loop from 1 to 24, running timeout... each time, which waits 3600 seconds and then executes the command.

See page: timeout command.

stderr

Posted 2013-07-22T13:45:39.800

Reputation: 9 300

I'm on Win 10 and with such syntax it doesn't work saying "ERROR: Invalid syntax. Default option is not allowed more than '1' time(s)." So, I've just put a "&" before the command making it for /L %i in (1,1,5) do timeout /T 10 & <command>. The only disadvantage is that it prints "Waiting for 0 seconds, press a key to continue ..." all the time between the command executions. – RAM237 – 2019-05-31T16:22:18.587