San Francisco -- Some 2,000 San Francisco students who still lacked proof of a whooping cough vaccination one month into the school year were barred from class Thursday and told not to return until they got the shot.

A new state law requires all children in grades seven through 12 to have the vaccine by the first day of school this year, but districts struggling to get families to comply asked for and received a 30-day extension.

San Francisco, which had a mid-August start to school, was among the first districts in the state to enforce the new measure.

The law applies to both public and private school students in an age group that is most likely to spread a disease that is a racking three-month illness for adults and a potentially deadly disease for infants.

Despite phone calls to homes, several written reminders in multiple languages, daily in-school announcements and free community vaccination clinics, 10 percent of the district's 24,000 middle and high school students still hadn't complied by Thursday's deadline, district officials said.

It was a vast improvement from the 8,000 students who hadn't submitted the required vaccination paperwork by Sept. 1, district officials said.

"I'm so glad it's such a relatively small number of students now," said district spokeswoman Heidi Anderson.

On Thursday, school officials told the 2,000 students to either get the paperwork from their medical provider or report to a free vaccination clinic set up in a conference room at the school district's central office.

More for you News Whooping cough vaccine's durability questioned

Students started lining up before the 7 a.m. start to get the shot. After two hours, 100 students had filed through the line.

Shortly after 9 a.m., John O'Connell High School senior Joseph Chavez sat at the conference table, rolled up his sleeve and looked away as a nurse pushed a needle into his arm.

"That's it?" he asked a few seconds later. "It hurt more to get my tongue (pierced)."

Chavez said it had been a busy summer and he just hadn't gotten around to getting the booster shot. So instead of sitting in physics class, he was sitting in a conference room getting stuck with a needle. He hoped to make it back to school for his Advanced Placement English class.

Many children receive whooping cough, or pertussis, vaccine as infants. Then after age 7, they typically get a Tdap booster shot, which also includes immunization for tetanus and diphtheria.

For all required immunizations, state law includes an opt-out provision based on medical reasons or personal beliefs. Parents must fill out an exemption form at their children's schools.

The Legislature passed the new pertussis vaccination law last September in response to a rise in the number of cases across the state.

In 2010, there were 9,000 reported cases of whooping cough in California, including 10 infant deaths, according to the state Department of Public Health.

It was the highest number of cases since 1947.