Whenever a fine or penalty is imposed for neglect for any period of time, the neglect may be alleged to have begun at any specified time and shall be reckoned from the time so alleged; but no suit or prosecution in such case shall be begun against a town or town officers until 20 days after notice in writing of the intention to begin it, nor then, if, within that time, the duty is performed.