These are kitchen cabinets.
The structure is 90 years old and lots of settling has taken place not to mention leaks in walls, etc. so whatever distortions exist are a compounded issue.
I doubt these shelves will move by my hand, but if they move it will be with the building structure.
Everything is affixed and dependent on everything else (also some shelves are nailed to case side-partitions) so whacking on the shelves to move them against the wall isn't going to happen without unforseen consequences ... not to mention the gaps are only 1/2" wide in some places at other places it's stopped up. Not all the shelves have gaps, and where they exist they aren't uniform in width. I'm looking to conceal them so they look OK and with minimal effort and time.
The back wall where the shelves connect was recently skim coated. The gaps were for the most part not excavated at that time by the workers, in fact most of the gaps weren't visible, they were concealed. There was tape visible on the shelves under the paint some of which had been disturbed by the pre-skim coat prep scraping. Someone at some time had used what looks like duct tape or cloth tape to seal the gaps on the backs and sides of the shelves. So buried underneath the layers of paint was tape.
When I scraped and sanded the paint off the shelves I ripped out most of the tape, but I didn't excavate the gaps as to do so would have opened up another can of worms, entailed way too much labor, and probably necessitating re-skimming the wall. One has to cut their loses at some point or there's no end in sight. Besides I was just planning to cover them over anyway so why go to the trouble of scraping them out.
So here's what I did:
Ripped up the tape except for on the top shelf (at 8' high where it's not visible and seldom accessed anyway) and that of course now exposed the largish gaps. So the tape was a prior tenant's solution to the gaps. I stripped the paint from the tops of the shelves with a scraper and belt sander, the shelf tops had that tape but were also covered in a layer or two of some sort of adhesive backed contact paper buried under the paint and with dozens of staples standing proud to hold the contact paper. What can I say it was a nightmare(!) ... all that buried with dozens of layers of paint.
When embarking on this project I wasn't intending to touch the shelving or cabinet interior at all. However it sort of fell to my hand as the memory of gross kitchen cabinets remained, so I plunged ahead. I stripped the shelf tops of tape, contact paper, paint, staples, crud. The bottom side of the shelving I didn't strip (but they weren't as bad: no contact paper, staples, etc) but knocked off the high spots and used Ready Patch on the rougher areas to provide a smooth surface. I even stripped most of the paint out of the grooved front edge of the shelving by making a blade for a Stanley #66 beader. A lot of work. I wasn't looking for perfect ... but rather an acceptably freshened interior.
Then, I primed the shelving with alkyd paint.
I'm thinking to just use caulk wheres the gaps is up to 1/4", then prime again, and paint.
And on the lower shelving that's visible at eye level and with wider gaps, maybe fill with caulk first then put a strip of wood as molding over it. It will look clean, straight, crisp.
Then do the second coat of primer.
Then the top coat.