I'm trying to write a simple check code which reads the log filename (after backup) from a given directory and gives information if log with present date was created or if it wasn't. Code should and with exit = 0 (TRUE) or exit = 2 (FALSE). Log is constructed from name and current date eg. log_2018_08_21) Please, any one may help me with it? I`m not really familiar with coding yet :/
import datetime import pathlib import sys filename = pathlib.Path("backup_" + datetime.datetime.now() + ".log") if filename.exists (): print ("File exist") sys.exit(0); else: print ("File not exist") sys.exit(2);