@@ -690,6 +690,11 @@ public function install_crontab()
690690 exec ('crontab -u root -l > crontab.txt ' );
691691 $ existing_root_cron_jobs = file ('crontab.txt ' );
692692
693+ // remove existing ispconfig cronjobs, in case the syntax has changed
694+ foreach ($ existing_root_cron_jobs as $ key => $ val ) {
695+ if (stristr ($ val ,'/usr/local/ispconfig ' )) unset($ existing_root_cron_jobs [$ key ]);
696+ }
697+
693698 $ root_cron_jobs = array (
694699 '* * * * * /usr/local/ispconfig/server/server.sh &> /dev/null ' ,
695700 '30 00 * * * /usr/local/ispconfig/server/cron_daily.sh &> /dev/null '
@@ -704,19 +709,27 @@ public function install_crontab()
704709 unlink ('crontab.txt ' );
705710
706711 //* Getmail crontab
707- $ cf = $ conf ['getmail ' ];
708- exec ('crontab -u getmail -l > crontab.txt ' );
709- $ existing_cron_jobs = file ('crontab.txt ' );
710-
711- $ cron_jobs = array ('*/5 * * * * ' .$ cf ['program ' ].' -g ' .$ cf ['config_dir ' ].' -r ' .$ cf ['config_dir ' ].'/*.conf &> /dev/null ' );
712- foreach ($ cron_jobs as $ cron_job ) {
713- if (!in_array ($ cron_job ."\n" , $ existing_cron_jobs )) {
714- $ existing_cron_jobs [] = $ cron_job ."\n" ;
712+ if (is_user ('getmail ' )) {
713+ $ cf = $ conf ['getmail ' ];
714+ exec ('crontab -u getmail -l > crontab.txt ' );
715+ $ existing_cron_jobs = file ('crontab.txt ' );
716+
717+ $ cron_jobs = array ('*/5 * * * * ' .$ cf ['program ' ].' -g ' .$ cf ['config_dir ' ].' -r ' .$ cf ['config_dir ' ].'/*.conf &> /dev/null ' );
718+
719+ // remove existing ispconfig cronjobs, in case the syntax has changed
720+ foreach ($ cron_jobs as $ key => $ val ) {
721+ if (stristr ($ val ,$ cf ['program ' ])) unset($ cron_jobs [$ key ]);
715722 }
723+
724+ foreach ($ cron_jobs as $ cron_job ) {
725+ if (!in_array ($ cron_job ."\n" , $ existing_cron_jobs )) {
726+ $ existing_cron_jobs [] = $ cron_job ."\n" ;
727+ }
728+ }
729+ file_put_contents ('crontab.txt ' , $ existing_cron_jobs );
730+ exec ('crontab -u getmail crontab.txt &> /dev/null ' );
731+ unlink ('crontab.txt ' );
716732 }
717- file_put_contents ('crontab.txt ' , $ existing_cron_jobs );
718- exec ('crontab -u getmail crontab.txt &> /dev/null ' );
719- unlink ('crontab.txt ' );
720733 }
721734
722735}
0 commit comments