HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (
-   Installation/Configuration (
-   -   Cron job runs on both master and mirror server, why? (

snowfly 25th July 2011 05:17

Cron job runs on both master and mirror server, why?
I have 2 web servers running ISPconfig 3, first server is master, and second is set to be "Is mirror of Server" master.

When creating cron jobs on the master server using ISPConfig, it appears these cron jobs are replicated across on the mirror.
Hence our crons are run twice.

e.g. I have a cron to hit a PHP script (URL cron), and the PHP script sends me an email.
I get the email twice, because both the master and mirror server run the cron.

How do I get the mirror server to not run crons?
I only use the mirror server as a backup, and ISPConfig mirrors all the config, and I use rsync to mirror data.

CSsab 25th July 2011 06:56

No cron on mirror
Hi Snowfly,

The cron jobs give up-to-date information about whats happening on the mirror so IMO it's not a good idea not to have the cron jobs running.

Maybe there is something you could do with your email script which prevents the mirror from sending you mail.

If you still want to edit the cron jobs you can do this:

As root on the mirror

crontab -e

select your editor (<----- most likely "vim")

and you should see these 2 jobs:

* * * * * /usr/local/ispconfig/server/ > /dev/null 2>> /var/log/ispconfig/cron.log
30 00 * * * /usr/local/ispconfig/server/ > /dev/null 2>> /var/log/ispconfig/cron.log

You can comment them # to stop them from running.

snowfly 25th July 2011 08:27

Hi CSsab,

No I do not mean the ISPConfig cron script.
I am talking about user/client cron scripts.

These are listed under /etc/cron.d/

For example, on my master server I have:

And on my mirror server I also have:

And both contain the same (where URL is my PHP script):
*/5 * * * * web26 /usr/bin/wget -q -O /dev/null '<URL>' >/dev/null 2>&1

So the PHP script gets run twice, and I get to emails sent to me, because at the bottom of the PHP script I put a php mail(...) command.

So wanting to know a way to stop user/client cron jobs getting replicated and run on the mirror server.

CSsab 25th July 2011 09:38

You can exclude a file, files and an entire directory using the:

$ rsync -avz --exclude


So you could either exclude anything in etc/cron.d/
or the entire directory etc/cron.d from being backed up on the mirror.

Did you use a guide to set up rsync? If so which one?

snowfly 25th July 2011 10:18


Originally Posted by CSsab (Post 260329)
You can exclude a file, files and an entire directory using the:

$ rsync -avz --exclude


Sorry you still misunderstand my problem.
This has nothing to do with rsync.

This is to do with internal ISPConfig functionality.

In ISPConfig I have configured my backup server to Mirror the master server.
This is done under: System > Server Services > {click on backup server} > Select option "Is mirror of Server" > {select master server from drop down box}

With this setting, every action I submit on my ISPConfig control panel for the master server, is replicated / mirrored on the backup server.

- I create a web domain on master server, web domain settings (not content) is mirrored on backup server
- I create an FTP user on master server, FTP user is mirrored on backup server

And when I create a client cron job on the master server (Under Sites > Cron Jobs > Add new Cron Job)
This cron job is replicated on the backup server.

ISPConfig itself creates the cron job on the master server at:

And ISPConfig on the backup server creates the cron job on the backup server:

Make sense?

CSsab 25th July 2011 11:16

Yes I understand what you mean - sorry about the confusion.

I only use the mirror function for DNS - that is to say, my ns2 is a mirror of ns1 and those two are not used for anything else.

I would use rsync to back up everything else.

Have you tried doing something like this:

On the slave as root:

cp /etc/cron.d/ispc_web26 /etc/cron.d/ispc_web26.ORIG
rm /etc/cron.d/ispc_web26
vi /etc/cron.d/ispc_web26

## put something here... save and close file

chmod -x /etc/cron.d/ispc_web26

The mirror function on the master may not be able to overwrite the file then.

But maybe there would be errors.

snowfly 28th July 2011 04:42

That wouldn't work, as its only stopping one specific cron, not multiple crons.

Any cron I setup on master is also setup on backup (mirror)
So every cron is run twice.

Must be a way to stop this?

mattltm 15th May 2013 22:37

Did this ever get resolved?

I am having a nightmare with duplicate cron entries!

All times are GMT +2. The time now is 06:21.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.