import os,datetime # Also add this line into crontab: # * * * * * /usr/bin/python2.7 /data/www/exam_aiacademy_tw/wp-content/db-error_detect.py > /data/www/exam_aiacademy_tw/wp-content/log_output_access_deny/db-error_detect.py.output ABS_PATH = os.path.dirname(os.path.realpath(__file__)) + '/' db_error_flag_file_path = ABS_PATH + 'uploads/db-error.txt' if os.path.exists(db_error_flag_file_path) and os.path.isfile(db_error_flag_file_path): os.remove(db_error_flag_file_path) os.system('/etc/init.d/mysqld restart') print 'Done @ '+str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'));