Patch-Source: https://src.fedoraproject.org/rpms/at/blob/f36/f/at-3.1.16-clear-nonjobs.patch (updated)
--
From c65246e094527163ee0b2003041ff6c942e14e47 Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
Date: Sep 09 2015 12:07:23 +0000
Subject: clear non-job files from at dir

diff --git a/atd.c b/atd.c
--- a/atd.c
+++ b/atd.c
@@ -401,10 +401,22 @@ run_file(const char *filename, uid_t uid, gid_t gid)
     sprintf(fmt, "#!/bin/sh\n# atrun uid=%%d gid=%%d\n# mail %%%ds %%d",
 	mailsize );
 
+    /* Unlink the file unless there was an error reading it (perhaps
+     * temporary).
+     * If the file has a bogus format there is no reason in trying
+     * to run it again and again.
+     */
     if (fscanf(stream, fmt,
-	       &nuid, &ngid, mailname, &send_mail) != 4)
-	pabort("File %.500s is in wrong format - aborting",
-	       filename);
+	       &nuid, &ngid, mailname, &send_mail) != 4) {
+		if (ferror(stream))
+			perr("Error reading the job file");
+
+		unlink(filename);
+		pabort("File %.500s is in wrong format - aborting",
+			filename);
+    }
+
+    unlink(filename);
 
     if (mailname[0] == '-')
 	pabort("illegal mail name %.300s in job %8lu (%.300s)", mailname,
@@ -414,12 +426,6 @@ run_file(const char *filename, uid_t uid, gid_t gid)
 	pabort("Job %8lu (%.500s) - userid %d does not match file uid %d",
 	       jobno, filename, nuid, uid);
 
-    /* We are now committed to executing this script.  Unlink the
-     * original.
-     */
-
-    unlink(filename);
-
     fclose(stream);
     if (chdir(ATSPOOL_DIR) < 0)
 	perr("Cannot chdir to " ATSPOOL_DIR);
