You can drive in whatever length timeslots suit you provided you're able to pause the game and leave the power on to your PS2.
Personally I've driven the 24hr races (Sarthe I & II and Nurb') 7 times in total, all in A-spec with no assistance. The shortest time I did one in was 3 days (8 hours driving per day) and the longest was 23 days! (An hour here & there for a while, though I was sent away on a business trip in the middle of the race, but left the PS2 on & paused while I was away, finishing the race when I got back.)
Unfortunately there is no "save" feature that'll allow you to restore your progress if you power down the console, so you'll have to set aside some time to run this race.
Best option is to run some of the race, hit "Start" to pause the game, and in the paused menu scroll down to "Screen Settings". Leave the power on to the PS2, and turn off the TV.
This way if anyone accidentally touches your controller it won't unpause the race, but will take you into "Brightness" & "Contrast" settings.
Stick a "Post-It" note with "DO NOT TOUCH!" over the power button too!
Provided your PS2 is in a well ventilated area it should not suffer from being left on for a long period of time.
B-speccing the race will take less time as you can have the PS2 do the driving, or some of the driving for you, however, you'll have to train your B-spec driver and still use an overkill car to make sure he wins. You can see my stats and opinion of B-spec in my signature though, and I'd advise against it. This is a racing game, not a "sitting & watching someone else race for me" game.
With A-spec you can engineer a fantastic race for yourself where you don't finish 10 laps ahead of everyone else, and in some surprising vehicles. If collecting A-spec points interests you, click the black link in my signature for the "Stock Car Race" thread for a list of cars that've been used, or have a read of this:
Nurburgring 24hr. 200 A-spec pts in stock Nissan C-West Razo Silvia (JGTC)