A tenancy from year to year may be terminated by either party giving notice in writing to the other, at least three months prior to the end of any year, of his intention to terminate the same. A periodic tenancy, in which the period is less than one year, may be terminated by like notice, or by notice for one full period before the end of any period. When such notice is to the tenant, it may be served upon him or upon anyone holding under him the leased premises, or any part thereof. When it is by the tenant, it may be served upon anyone who at the time owns the premises in whole or in part, or the agent of such owner, or according to the common law. This section shall not apply where, by special agreement, some other period of notice is fixed, or no notice is to be given; nor shall notice be necessary from or to a tenant whose term is to end at a certain time.