Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-09-20 : 14:06:51
|
HelloHow can I run a bat file every one hour or every 15 minutes. I was not able to do it using the widnows task schecduler.Thanks |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2006-09-20 : 14:13:48
|
Use "AT" an schedule it 24 times.The AT command schedules commands and programs to run on a computer ata specified time and date. The Schedule service must be running to usethe AT command.AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]AT [\\computername] time [/INTERACTIVE] [ /EVERY:date[,...] | /NEXT:date[,...]] "command"\\computername Specifies a remote computer. Commands are scheduled on the local computer if this parameter is omitted.id Is an identification number assigned to a scheduled command./delete Cancels a scheduled command. If id is omitted, all the scheduled commands on the computer are canceled./yes Used with cancel all jobs command when no further confirmation is desired.time Specifies the time when command is to run./interactive Allows the job to interact with the desktop of the user who is logged on at the time the job runs./every:date[,...] Runs the command on each specified day(s) of the week or month. If date is omitted, the current day of the month is assumed./next:date[,...] Runs the specified command on the next occurrence of the day (for example, next Thursday). If date is omitted, the current day of the month is assumed."command" Is the Windows NT command, or batch program to be run.But if you just want to do it in SQL server use xp_cmdshell"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-09-20 : 14:24:36
|
You don't need to use xp_cmdshell to run bat/cmd files in SQL Server if you are doing it through a job. You just need to select the cmdexec option in the job step. Windows task scheduler should do what you want though, so please let us know why it didn't work for you.Tara Kizer |
 |
|
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-09-20 : 15:07:49
|
The bat file , that I want to run is the script which checks the status of the sql server agent and mails the dba when it stops any moment. SO I want to schedule it every 15 minutes or 1 hour on the sql server 2000 , xp machine.I didnot see the option to run every 15 minutes in the widnows task scheduler.Thanks |
 |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2006-09-20 : 15:16:53
|
The option does not exist in the SchedulerInstead create 96 schedules 15 minutes apart that occur every day.(Easier to do in a batch file with AT)"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-09-20 : 15:22:32
|
Or just create 4 jobs. Each job runs every hour, but they are spaced by 15 minutes.Tara Kizer |
 |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2006-09-20 : 15:34:25
|
Oops my bad, the every 15 minute option is available.Schedule the task for daily, every day then select the checkbox to "Open advanced properties for this task when I click finish" Select the Schedule tab from pop up and go to Advanced. Also if what you are trying to do is monitor the server look into "Big Brother" It will do this test (every 15 mins) and many others out of the box. http://bb4.com/"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
|
|
|
|
|