Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a web application scoped feature that creates and submits a one-time timer job when the feature is activated. The purpose of the timer job is to copy a file from one directory to another on the file system of the machine running the job. The job should run on all WFE's in the farm.

Is it possible to programmatically check whether the file was successfully copied on all of the (remote) WFE's after the job completes? I find that even if the timer job claims to have successfully completed, the file may not have been copied on ALL servers.

For instance, I find that in some cases it is necessary to clear the SharePoint configuration cache on one or more servers before the timer would will successfully complete (cf. http://blogs.msdn.com/b/josrod/archive/2007/12/12/clear-the-sharepoint-configuration-cache-for-timer-job-and-psconfig-errors.aspx). Ideally, if that happens, I'd like to be able to tell the user (from an .aspx page) that the job failed to execute on one or more servers.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You could just use some error trapping in your code to determine if it completed or not. If it fails to find the file or fails to copy it, you should be able to detect that.

If I may ask a question though; is there a reason why you're doing this as a timer job, instead of just doing it in the feature receiver of the feature? I'd think you should be able to do it within the feature receiver giving you much more current status to relay to the user.

share|improve this answer
    
Hmm... interesting thought. The reason I went with a timer job is because I need to make sure the file gets copied on all front-end servers in the farm. I suppose I was under the impression that the feature receiver code only runs on one front-end. Is that not the case? –  jason.venema Aug 20 '10 at 18:42
    
You are correct, that the feature receiver only files on one WFE, so I may have made some assumptions in your post. What files are you copying? If they're within the SP Object model then you should be able to do it within the feature, but if you really are doing custom code then yes, your timer job route is probably on track. The example I was thinking of was of say, copying a masterpage from the package or from the 12/14 hive into the site itself. In that scenario you can fully accomplish all of that within the feature itself, and it will replicate those changes to all WFE's. –  webdes03 Aug 21 '10 at 14:34
    
I am copying a file to the root directory of the web application (C:\Inetpub\wwwroot\wss\VirtualDirectories[port]). The file needs to be copied on all WFE's, which is why I chose the timer job route. If I detect that the job fails on one server, would it be correct to throw an exception from my timer job code? How would that exception then be manifested to the administrator (ULS, event viewer, etc...)? –  jason.venema Aug 22 '10 at 1:13
    
Once you capture the exception in your timerjob you can do just about anything you want to do with it- write it to the syslog, email, create a task in a tasks list to assign it to someone for rework, etc. I'm still not positive that you need to go the timerjob route though. The root directory of the web app is available within the farm, I'm still not convinced that you can't do this with a simple line in the elements.xml file. What's the scope of the feature, and where does the file originate that you're copying to the web app root? –  webdes03 Aug 22 '10 at 2:54
    
The feature is web application scoped. The source file originates from the root directory of the feature (12\TEMPLATE\FEATURES\MyFeature). –  jason.venema Aug 24 '10 at 0:25
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.