I've done this on a few projects. I find the best way to keep motivated it to make myself accountable.
Even if no one is going to be looking at my code or what I'm doing, I still make it a priority to talk with either my supervisor, boss, or the PM and let them know where I'm at and what I plan on finishing by the end of the week. It takes 5min to run through it with them, and I've been told by a few PMs that it's really helpful to them as well.
For me it sets a goal, and a soft deadline that I want to meet. For the PM it lets them know where I'm at on the task and gives them time give their input.
If you can't do it face to face, fire off a short email. It's all about making yourself accountable for your tasks.
Also, try breaking a very large job down into small manageable and measurable tasks. Use a ticket tracking system and assign yourself tickets. This way you can manage how you're doing and keep yourself accountable for all the tasks you have to do.