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. this MSDN blog link). 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.

1 Answer 1


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.

  • 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? Aug 20, 2010 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, 2010 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...)? Aug 22, 2010 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, 2010 at 2:54
  • The feature is web application scoped. The source file originates from the root directory of the feature (12\TEMPLATE\FEATURES\MyFeature). Aug 24, 2010 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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