Index: programs/mythbackend/housekeeper.h
===================================================================
--- programs/mythbackend/housekeeper.h	(revision 11458)
+++ programs/mythbackend/housekeeper.h	(working copy)
@@ -19,10 +19,18 @@
 
     
   protected:
+    typedef struct mfdstruct
+    {
+        HouseKeeper *keep;
+        QString mfpath;
+        QString mfarg;
+        QString mflog;
+    } MFDStruct;
+
     void RunHouseKeeping(void);
     static void *doHouseKeepingThread(void *param);
 
-    void RunMFD(void);
+    void RunMFD(const MFDStruct *mfds);
     static void *runMFDThread(void *param);
 
   private:
@@ -31,12 +39,13 @@
     void updateLastrun(const QString &dbTag);
     QDateTime getLastRun(const QString &dbTag);
     void flushLogs();
-    void runFillDatabase();
+    void runFillDatabase(MFDStruct *mfds);
     void CleanupMyOldRecordings(void);
     void CleanupAllOldInUsePrograms(void);
     void CleanupRecordedTables(void);
     void CleanupExpiredRecordingRules(void);
     void CleanupOldrecordedTable(void);
+    void CleanupProgramListings(void);
     bool threadrunning;
     bool filldbRunning;
     bool isMaster;
Index: programs/mythbackend/housekeeper.cpp
===================================================================
--- programs/mythbackend/housekeeper.cpp	(revision 11458)
+++ programs/mythbackend/housekeeper.cpp	(working copy)
@@ -215,7 +215,19 @@
                         QString msg = "Running mythfilldatabase";
                         gContext->LogEntry("mythbackend", LP_DEBUG, msg, "");
                         VERBOSE(VB_GENERAL, msg);
-                        runFillDatabase();
+
+                        MFDStruct *mfds = new MFDStruct;
+
+                        mfds->mfpath = gContext->GetSetting(
+                                             "MythFillDatabasePath",
+                                             "mythfilldatabase");
+                        mfds->mfarg  = gContext->GetSetting(
+                                             "MythFillDatabaseArgs", "");
+                        mfds->mflog  = gContext->GetSetting(
+                                             "MythFillDatabaseLog",
+                                             "/var/log/mythfilldatabase.log");
+
+                        runFillDatabase(mfds);
                         updateLastrun("MythFillDB");
                     }
                 }
@@ -225,8 +237,9 @@
                 JobQueue::CleanupOldJobsInQueue();
                 CleanupAllOldInUsePrograms();
                 CleanupRecordedTables();
                 CleanupExpiredRecordingRules();
                 CleanupOldrecordedTable();
+                CleanupProgramListings();
                 updateLastrun("DailyCleanup");
             }
         }
@@ -266,21 +279,27 @@
 
 void *HouseKeeper::runMFDThread(void *param)
 {
-    HouseKeeper *keep = (HouseKeeper *)param;
-    keep->RunMFD();
+    MFDStruct *mfds = (MFDStruct *)param;
+
+    HouseKeeper *keep = mfds->keep;
+    keep->RunMFD(mfds);
+
+    delete mfds;
+
     return NULL;
 }
 
-void HouseKeeper::RunMFD(void)
+void HouseKeeper::RunMFD(const MFDStruct *mfds)
 {
     QString command;
 
-    QString mfpath = gContext->GetSetting("MythFillDatabasePath",
-                                          "mythfilldatabase");
-    QString mfarg = gContext->GetSetting("MythFillDatabaseArgs", "");
-    QString mflog = gContext->GetSetting("MythFillDatabaseLog",
-                                         "/var/log/mythfilldatabase.log");
+    QString mfpath = mfds->mfpath;
+    if (mfpath == "mythfilldatabase")
+        mfpath = gContext->GetInstallPrefix() + "/bin/mythfilldatabase";
 
+    QString mfarg = mfds->mfarg;
+    QString mflog = mfds->mflog;
+
     if (mflog == "")
         command = QString("%1 %2").arg(mfpath).arg(mfarg);
     else
@@ -292,7 +311,7 @@
     HouseKeeper_filldb_running = false;
 }
 
-void HouseKeeper::runFillDatabase()
+void HouseKeeper::runFillDatabase(MFDStruct *mfds)
 {
     if (HouseKeeper_filldb_running)
         return;
@@ -300,7 +319,7 @@
     HouseKeeper_filldb_running = true;
 
     pthread_t housekeep_thread;
-    pthread_create(&housekeep_thread, NULL, runMFDThread, this);
+    pthread_create(&housekeep_thread, NULL, runMFDThread, mfds);
     pthread_detach(housekeep_thread);
 }
 
@@ -368,6 +387,21 @@
     query.exec();
 }
 
+void HouseKeeper::CleanupProgramListings(void)
+{
+    if (!gContext->GetNumSetting("MythFillEnabled", 0))
+    {
+        MFDStruct *mfds = new MFDStruct;
+
+        mfds->mfpath = "mythfilldatabase";
+        mfds->mfarg  = "--do-cleanup-only --no-delete";
+        mfds->mflog  = gContext->GetSetting("MythFillDatabaseLog",
+                                            "/var/log/mythfilldatabase.log");
+
+        runFillDatabase(mfds);
+    }
+}
+
 void *HouseKeeper::doHouseKeepingThread(void *param)
 {
     HouseKeeper *hkeeper = (HouseKeeper*)param;
Index: programs/mythfilldatabase/filldata.cpp
===================================================================
--- programs/mythfilldatabase/filldata.cpp	(revision 11458)
+++ programs/mythfilldatabase/filldata.cpp	(working copy)
@@ -62,6 +62,7 @@
 bool dd_grab_all = false;
 bool dddataretrieved = false;
 bool mark_repeats = true;
+bool do_cleanup_only = false;
 bool channel_updates = false;
 bool channel_update_run = false;
 bool remove_new_channels = false;
@@ -3591,6 +3592,12 @@
         {
              mark_repeats = false;
         }
+        else if (!strcmp(a.argv()[argpos], "--do-cleanup-only"))
+        {
+            do_cleanup_only = true;
+            grab_data = false;
+            mark_repeats = false;
+        }
         else if (!strcmp(a.argv()[argpos], "--export-icon-map"))
         {
             export_iconmap = true;
@@ -3746,6 +3753,11 @@
             cout << "--reset-icon-map [all]\n";
             cout << "   Resets your icon map (pass all to reset channel icons as well)\n";
             cout << "\n";
+#if 0
+            cout << "--do-cleanup-only\n";
+            cout << "   Cleans old program listings from the database.\n";
+            cout << "\n";
+#endif
             cout << "--mark-repeats\n";
             cout << "   Marks any programs with a OriginalAirDate earlier\n";
             cout << "   than their start date as a repeat\n";
@@ -3987,6 +3999,11 @@
                 QString("    Found %1").arg(query.numRowsAffected()));
     }
 
+    if (do_cleanup_only)
+    {
+        clearOldDBEntries();
+    }
+
     if (mark_repeats)
     {
         VERBOSE(VB_GENERAL, "Marking repeats.");
Index: programs/mythfrontend/globalsettings.cpp
===================================================================
--- programs/mythfrontend/globalsettings.cpp	(revision 11458)
+++ programs/mythfrontend/globalsettings.cpp	(working copy)
@@ -2919,10 +2919,11 @@
 static GlobalLineEdit *MythFillDatabasePath()
 {
     GlobalLineEdit *be = new GlobalLineEdit("MythFillDatabasePath");
-    be->setLabel(QObject::tr("mythfilldatabase Path"));
-    be->setValue(gContext->GetInstallPrefix() + "/bin/mythfilldatabase");
-    be->setHelpText(QObject::tr("Path (including executable) of the "
-                    "mythfilldatabase program."));
+    be->setLabel(QObject::tr("mythfilldatabase Program"));
+    be->setValue("mythfilldatabase");
+    be->setHelpText(QObject::tr("Use 'mythfilldatabase' or the name of a "
+                    "custom script that will populate the program guide info "
+                    "for you."));
     return be;
 }
 
