Problem
Running the script /usr/share/ucs-school-exam/exam-and-room-cleanup fails immediately with a FileNotFoundError. The error occurs when the script attempts to write debug output or change ownership of the logfile /var/log/univention/ucs-school-exam-cleanup.log. As a result, the exam cleanup process cannot be executed.
Root Cause
The script assumes that the logfile already exists after calling ud.init(LOGFILE, …). However, ud.init() does not always create the logfile reliably. When the script reaches the line:
os.chown(LOGFILE, 0, adm.gr_gid)
the file may not yet exist. This leads to the following error:
FileNotFoundError: [Errno 2] No such file or directory: '/var/log/univention/ucs-school-exam-cleanup.log'
Manually creating the logfile confirms that the missing file is the only blocker. This behavior indicates a bug in the script: it does not verify or create the logfile before attempting to modify its ownership and permissions.
Solution
To resolve the issue immediately, create the logfile manually and set the expected permissions:
touch /var/log/univention/ucs-school-exam-cleanup.log
chown root:adm /var/log/univention/ucs-school-exam-cleanup.log
chmod 640 /var/log/univention/ucs-school-exam-cleanup.log
Afterwards, the script can be executed successfully:
/usr/share/ucs-school-exam/exam-and-room-cleanup -d