The state turned to contractors in 2018 after failing to attract enough laborers, a trend across governments as they look for more flexible staffing. It resulted in fraud and inefficiencies, so Mr. Baer got raises approved this year, which helped him find enough new workers to satisfy the state’s needs.

“We knew it was going to be a struggle to compete,” he said.

For people like Cynthia Cuffie, 62, the more aggressive push to hire has created opportunities.

Ms. Cuffie has not worked formally in years. The Hartsville, S.C., resident lives in a house her mother left her and helps take care of her sister, who in turn pays for Ms. Cuffie’s basic living expenses. But peanut inspecting could allow her to better maintain her beloved truck, a 1997 Toyota T-100 given to her by a relative. When she saw the peanut-inspector job advertised on Facebook, she knew she ought to try for it.

“It’s going to do marvels for me,” said Ms. Cuffie, who landed the gig and began training on Aug. 20. She is planning to repay her sister for new tires she has just bought, and then pay tithes at her church. “It’s going to get me out of the hole.”

In Washington State, a shortage of information technology and health care workers has prompted it to compete with the private sector despite budgetary constraints, said Franklin Plaistowe, assistant director of the state’s human resources division. To attract workers, it touts its public service-oriented mission, as well as good benefits and unique perks: Some employees can now bring their infants to the office.

“We’ve had four babies come through and retire,” Mr. Plaistowe said of his own department. “We’re thinking, from a human perspective, of our employees, and how we can meet them where they are.”

Gerald Young, a researcher at the nonprofit Center for State and Local Government Excellence, said he has seen governments in Iowa share health care personnel across county lines, and school districts in Nebraska allow science and math teachers to return from retirement to fill workplace gaps.