Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find if Agent is runing 1

Status
Not open for further replies.

wg26

Programmer
Mar 21, 2002
135
0
0
US
Hi Everyone:

I am adding a job to MSDE. But as I understand, in order for the job to run, agent must be started and running. Since MSDE does not have EM, how can I tell if the agent is running? if it is not, how to use T_SQL to start the agent? Can anyone kindly give me some help? Thanks alot
 
This sql script should do the job -

USE MASTER

DECLARE @cmd varchar(100)

CREATE TABLE #TEMP (
[description] [varchar] (500)
) ON [PRIMARY]

SET @cmd = 'xp_cmdshell ''net start'''

INSERT INTO #TEMP EXEC(@cmd)

IF NOT EXISTS (SELECT * from #temp where description like '%SQLSERVERAGENT%')
BEGIN
SET @cmd = 'xp_cmdshell ''net start SQLSERVERAGENT'''
EXEC(@cmd)
END
DROP TABLE #TEMP
 
on each servers
I have created a job that send a mail to a choosen master server (nearest of my office).
This mail contains a statement that update a status table (srv_name, status, date)

On the main server
I update my status table setting all switch to 0.
On the "main" server i process all received mails setting my switch to 1.

I scan my table for any switch to 0. If any i receive a warning in my mailbox.

So i can be warned if agent or mail are down.
 
Thanks guys for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top