HOUSTON (Reuters) - U.S. oil services companies have been doing a lot more work as recovering oil prices have lifted the shale industry from a two-year slump, but producers have been pocketing much of the new cash generated by rising output and squeezing service providers to keep costs down.

FILE PHOTO: An oil pump is seen operating in the Permian Basin near Midland, Texas, U.S. on May 3, 2017. REUTERS/Ernest Scheyder

Oil service companies that provide the crews, labor and technology used to drill, construct and operate wells are lagging the recovery in U.S. shale producers. The lopsided situation could chill the production rebound or keep it from spreading to more shale fields, executives of services companies said.

Rising demand for certain services means raising salaries to attract workers and refurbishing equipment, while often being paid under fixed contracts signed during harder times, these companies said. That has pressured margins, leading to further losses. Law firm Haynes and Boone LLP said the U.S. oilfield sector experienced 127 bankruptcies between 2015 and April 2017.

Among the 10 largest oilfield service providers, just five were profitable last quarter, the same number as a year ago. In contrast, seven of the top shale oil producers posted a first quarter profit, up from just one a year ago.

"Both of us have to be able to earn a return and give something back to our shareholders," David Lesar, chief executive officer of Halliburton Co HAL.N, the world's second-largest oilfield services company, said in an interview.

The sector is struggling to change onerous contract terms set when oil prices were much lower. Service companies agreed to those prices out of necessity; they needed cash flow to cover expenses. Those contracts, some of which extend into next year, are contributing to losses, preventing some companies from adding equipment or moving it to oil fields where it could be put to use.

The expiration of those contracts should allow prices for high-demand services to rise, oilfield services executives said.

Even so, some of the changes that shale oil producers made during the downturn are likely to stick, making it harder for service firms to drive up prices.

Oil producers have better returns today because of those cost controls, winning greater favor among investors.

“Many of (oil producers) have reduced capex spending and are increasing capital returns to investors,” said Tom Bergeron, a senior fund manager for Frost Investment Advisors.

Shale firms have demanded deals that unbundle the functions of service providers, allowing them to spread the work out among more companies, who then have less leverage to raise prices.

Those practices allowed shale producer profits to start rebounding just a few months after oil prices began to recover from the $26 a barrel nadir of February 2016 Clc1. But it left services companies without a way to immediately benefit from the U.S. crude benchmark's return to about $50 a barrel.

Service companies hope they can raise prices by the second half of this year, but for now there is limited scope to pass along costs, Chakra Mandava, an operations executive at Nabors Drilling USA, NBR.N, said at an energy conference this month in Houston.

Nabors blamed its first quarter loss on an inability to offset costs for new staff and equipment.

Keane Group FRAC.N, which supplies pressure pumping services, one of the highest demand services in the shale patch, reported a first-quarter loss due largely to long-term, fixed price contracts, despite a 59 percent jump in revenue from the fourth quarter.

One proposal that might resolve the disconnect between oil price moves and contract changes is to tie deals to the cost of crude.

Apache Corp APA.N, which plans to drill some 250 wells this year in the Permian Basin, is looking to tie what it pays for services to the U.S. crude benchmark CLc1 - converting fixed service costs to a variable cost in order to cushion the hit to earnings of future oil-price changes.

That way, if crude prices rise, Apache could afford to pay more for services, but would pay less if oil drops. Chevron CVX.N also is tying some of its contracts to indexes in a bid to remain competitive, the company said at a recent security analysts meeting.

“We’re just opening up the business model to what’s possible,” Michael Behounek, a senior drilling advisor for Apache, said in May at a drilling conference in Houston. “We want to put a dampener in place.”

“They [service companies] don’t want to ride the roller coaster either. If we go down this route, it might be good for both parties.”