Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 25th July 2011, 04:17
snowfly snowfly is offline
Member
 
Join Date: Jul 2006
Posts: 93
Thanks: 0
Thanked 6 Times in 5 Posts
Default 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.
Reply With Quote
Sponsored Links
  #2  
Old 25th July 2011, 05:56
CSsab CSsab is offline
Senior Member
 
Join Date: Apr 2010
Posts: 174
Thanks: 19
Thanked 32 Times in 27 Posts
Default 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/server.sh > /dev/null 2>> /var/log/ispconfig/cron.log
30 00 * * * /usr/local/ispconfig/server/cron_daily.sh > /dev/null 2>> /var/log/ispconfig/cron.log


You can comment them # to stop them from running.
Reply With Quote
  #3  
Old 25th July 2011, 07:27
snowfly snowfly is offline
Member
 
Join Date: Jul 2006
Posts: 93
Thanks: 0
Thanked 6 Times in 5 Posts
Default

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:
/etc/cron.d/ispc_web26

And on my mirror server I also have:
/etc/cron.d/ispc_web26

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.
Reply With Quote
  #4  
Old 25th July 2011, 08:38
CSsab CSsab is offline
Senior Member
 
Join Date: Apr 2010
Posts: 174
Thanks: 19
Thanked 32 Times in 27 Posts
Default

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

$ rsync -avz --exclude

command.

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?

Last edited by CSsab; 25th July 2011 at 08:41.
Reply With Quote
  #5  
Old 25th July 2011, 09:18
snowfly snowfly is offline
Member
 
Join Date: Jul 2006
Posts: 93
Thanks: 0
Thanked 6 Times in 5 Posts
Default

Quote:
Originally Posted by CSsab View Post
You can exclude a file, files and an entire directory using the:

$ rsync -avz --exclude

command.
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.

e.g.
- 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:
/etc/cron.d/ispc_web26

And ISPConfig on the backup server creates the cron job on the backup server:
/etc/cron.d/ispc_web26

Make sense?
Reply With Quote
  #6  
Old 25th July 2011, 10:16
CSsab CSsab is offline
Senior Member
 
Join Date: Apr 2010
Posts: 174
Thanks: 19
Thanked 32 Times in 27 Posts
Default

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.
Reply With Quote
  #7  
Old 28th July 2011, 03:42
snowfly snowfly is offline
Member
 
Join Date: Jul 2006
Posts: 93
Thanks: 0
Thanked 6 Times in 5 Posts
Default

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?
Reply With Quote
  #8  
Old 15th May 2013, 21:37
mattltm mattltm is offline
Member
 
Join Date: Jun 2011
Posts: 72
Thanks: 16
Thanked 5 Times in 5 Posts
 
Default

Did this ever get resolved?

I am having a nightmare with duplicate cron entries!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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