setting featured image is not working while running script in background, works when running that script from browser

Ohh Sorry, It was my mistake! It was caching problem.

Whoever facing such problems, just try to disable Database Cache(of Total Cache) plugin.
This caching is now pre-inistalled in all your new wordpress installation.