A trashcan automatically opens and closes a trashcan lid and prevents offensive odor due to UV (ultraviolet) disinfection. The trashcan includes a case whose upper face is openable a lid coupled to the case to be opened and closed and to seal the trashcan, and a sterilizer on the lid generating ultraviolet rays and ozone toward the trashcan for sterilization and deodorization. An opening and closing unit automatically opens and closes the lid by sensing user access. A microcomputer controls operation of the UV sterilization lamp at regular intervals when the lid is closed and the opening and closing unit. Accordingly, it is possible to prevent offensive odor from being caused by sterilizing and deodorizing the inside of the trashcan, and it is convenient for users to discard waste or dirt into the trashcan by automatically opening the trashcan lid for a certain time according to the user access.