Difference between revisions of "Step to rebuild crontab file of zimbra user"

(Step to rebuilt crontab file of zimbra user)
Line 1: Line 1:
===<h1>Step to rebuilt crontab file of zimbra user</h1>===
+
==<h1>Step to rebuilt crontab file of zimbra user</h1>==
 
<hr>
 
<hr>
 
<br>
 
<br>
 
<h2>Problem</h2>
 
<h2>Problem</h2>
  
Default crontab of zimbra user removed accidentally.
+
Default crontab of zimbra user removed accidentally.<br>
 
+
'''OR'''<br>
'''OR'''
 
 
 
 
System admin removed some entries from the crontab file.
 
System admin removed some entries from the crontab file.
  
Line 14: Line 12:
 
Steps to restore or rebuilt crontab entries for the zimbra user on different ZCS environments.
 
Steps to restore or rebuilt crontab entries for the zimbra user on different ZCS environments.
  
====(A)  Steps for single-server setup :====
+
===(A)  Steps for single-server setup: ===
 +
 
 +
First we have to take backup of current crontab file, then we will use following commands to re-built crontab for zimbra user.
  
First we have to take backup of current crontab file, then we will use following command to re-built crontab for zimbra user.
+
==== On ZCS v8.6: ==== 
 +
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK 
 +
cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
 +
cat /opt/zimbra/zimbramon/crontabs/crontab.ldap >> /tmp/cron.zimbra
 +
cat /opt/zimbra/zimbramon/crontabs/crontab.store >> /tmp/cron.zimbra
 +
cat /opt/zimbra/zimbramon/crontabs/crontab.logger >> /tmp/cron.zimbra
 +
cat /opt/zimbra/zimbramon/crontabs/crontab.mta >> /tmp/cron.zimbra
 +
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra
 +
crontab -u zimbra /tmp/cron.zimbra 
 +
su - zimbra -c "zmschedulebackup -D"
  
<pre>
+
==== On ZCS v8.7.x: ==== 
# cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK   
+
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK   
# cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
+
cat /opt/zimbra/conf/crontabs/crontab > /tmp/cron.zimbra
# cat /opt/zimbra/zimbramon/crontabs/crontab.ldap >> /tmp/cron.zimbra
+
cat /opt/zimbra/conf/crontabs/crontab.ldap >> /tmp/cron.zimbra
# cat /opt/zimbra/zimbramon/crontabs/crontab.store >> /tmp/cron.zimbra
+
cat /opt/zimbra/conf/crontabs/crontab.store >> /tmp/cron.zimbra
# cat /opt/zimbra/zimbramon/crontabs/crontab.logger >> /tmp/cron.zimbra
+
cat /opt/zimbra/conf/crontabs/crontab.logger >> /tmp/cron.zimbra
# cat /opt/zimbra/zimbramon/crontabs/crontab.mta >> /tmp/cron.zimbra
+
cat /opt/zimbra/conf/crontabs/crontab.mta >> /tmp/cron.zimbra
# echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra  
+
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra  
# crontab -u zimbra /tmp/cron.zimbra   
+
crontab -u zimbra /tmp/cron.zimbra   
# su - zimbra -c "zmschedulebackup -D"  
+
su - zimbra -c "zmschedulebackup -D"  
# /etc/init.d/crond restart 
 
</pre>
 
  
====(B)  Steps for multi-server setup :====
+
 
 +
 
 +
===(B)  Steps for multi-server setup: ===
  
 
Here we have mentioned the commands according to the role of ZCS server.
 
Here we have mentioned the commands according to the role of ZCS server.
  
=====LDAP Server :=====
+
==== On ZCS v8.6: ==== 
 +
===== LDAP Server: =====
 +
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK
 +
cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
 +
cat /opt/zimbra/zimbramon/crontabs/crontab.ldap >> /tmp/cron.zimbra 
 +
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra 
 +
crontab -u zimbra /tmp/cron.zimbra 
 +
su - zimbra -c "zmschedulebackup -D"
  
<pre>
+
===== Mailbox Server: =====
# cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK  
+
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK  
# cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
+
cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
# cat /opt/zimbra/zimbramon/crontabs/crontab.ldap >> /tmp/cron.zimbra   
+
cat /opt/zimbra/zimbramon/crontabs/crontab.store >> /tmp/cron.zimbra
# echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra   
+
  echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra   
# crontab -u zimbra /tmp/cron.zimbra   
+
crontab -u zimbra /tmp/cron.zimbra   
# su - zimbra -c "zmschedulebackup -D"  
+
su - zimbra -c "zmschedulebackup -D"  
# /etc/init.d/crond restart
+
/etc/init.d/crond restart
</pre>
 
  
=====Mailbox Server :=====
+
===== MTA+Proxy Server: =====
 +
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK 
 +
cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
 +
cat /opt/zimbra/zimbramon/crontabs/crontab.mta >> /tmp/cron.zimbra
 +
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra
 +
crontab -u zimbra /tmp/cron.zimbra 
  
<pre>
+
# cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK  
+
==== On ZCS v8.7.x: ==== 
# cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
+
===== LDAP Server: =====
# cat /opt/zimbra/zimbramon/crontabs/crontab.store >> /tmp/cron.zimbra
+
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK  
# echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra   
+
cat /opt/zimbra/conf/crontabs/crontab > /tmp/cron.zimbra
# crontab -u zimbra /tmp/cron.zimbra   
+
cat /opt/zimbra/conf/crontabs/crontab.ldap >> /tmp/cron.zimbra
# su - zimbra -c "zmschedulebackup -D"  
+
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra   
# /etc/init.d/crond restart
+
crontab -u zimbra /tmp/cron.zimbra   
</pre>
+
su - zimbra -c "zmschedulebackup -D"  
  
=====MTA+Proxy Server :=====
+
===== Mailbox Server: =====
 +
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK
 +
cat /opt/zimbra/conf/crontabs/crontab > /tmp/cron.zimbra
 +
cat /opt/zimbra/conf/crontabs/crontab.store >> /tmp/cron.zimbra
 +
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra 
 +
crontab -u zimbra /tmp/cron.zimbra 
 +
su - zimbra -c "zmschedulebackup -D"
  
<pre>
+
===== MTA+Proxy Server: =====
# cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK   
+
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK   
# cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
+
cat /opt/zimbra/conf/crontabs/crontab > /tmp/cron.zimbra
# cat /opt/zimbra/zimbramon/crontabs/crontab.mta >> /tmp/cron.zimbra
+
cat /opt/zimbra/conf/crontabs/crontab.mta >> /tmp/cron.zimbra
# echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra  
+
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra  
# crontab -u zimbra /tmp/cron.zimbra   
+
crontab -u zimbra /tmp/cron.zimbra   
# /etc/init.d/crond restart
 
</pre>
 
  
'''Note :'''
 
  
We have to restart Cron service after installing new crontab file.
 
  
'''Here is the commands to restart Cron service on different OS versions.'''
+
'''Note :'''  We have to restart Cron service after installing new crontab file.
  
Ubuntu 12.04/14.04
+
'''Commands to restart Cron service on different OS versions.'''
  
 +
Ubuntu 12.04/14.04/16.04
 
  service cron restart
 
  service cron restart
  
 
RHEL/CentOS 7.x
 
RHEL/CentOS 7.x
 
 
  systemctl restart crond
 
  systemctl restart crond
systemctl status crond
 
  
 
RHEL/CentOS 6.x
 
RHEL/CentOS 6.x
 
 
  service crond restart
 
  service crond restart
  
  
  
Heera Singh
 
  
<hsingh@zimbra.com>
+
Submitted by:  Heera Singh Koranga

Revision as of 20:42, 20 August 2017

Step to rebuilt crontab file of zimbra user



Problem

Default crontab of zimbra user removed accidentally.
OR
System admin removed some entries from the crontab file.

Solution

Steps to restore or rebuilt crontab entries for the zimbra user on different ZCS environments.

(A) Steps for single-server setup:

First we have to take backup of current crontab file, then we will use following commands to re-built crontab for zimbra user.

On ZCS v8.6:

cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK  
cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
cat /opt/zimbra/zimbramon/crontabs/crontab.ldap >> /tmp/cron.zimbra
cat /opt/zimbra/zimbramon/crontabs/crontab.store >> /tmp/cron.zimbra
cat /opt/zimbra/zimbramon/crontabs/crontab.logger >> /tmp/cron.zimbra
cat /opt/zimbra/zimbramon/crontabs/crontab.mta >> /tmp/cron.zimbra
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra 
crontab -u zimbra /tmp/cron.zimbra   
su - zimbra -c "zmschedulebackup -D" 

On ZCS v8.7.x:

cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK  
cat /opt/zimbra/conf/crontabs/crontab > /tmp/cron.zimbra
cat /opt/zimbra/conf/crontabs/crontab.ldap >> /tmp/cron.zimbra
cat /opt/zimbra/conf/crontabs/crontab.store >> /tmp/cron.zimbra
cat /opt/zimbra/conf/crontabs/crontab.logger >> /tmp/cron.zimbra
cat /opt/zimbra/conf/crontabs/crontab.mta >> /tmp/cron.zimbra
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra 
crontab -u zimbra /tmp/cron.zimbra   
su - zimbra -c "zmschedulebackup -D" 


(B) Steps for multi-server setup:

Here we have mentioned the commands according to the role of ZCS server.

On ZCS v8.6:

LDAP Server:
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK 
cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
cat /opt/zimbra/zimbramon/crontabs/crontab.ldap >> /tmp/cron.zimbra  
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra  
crontab -u zimbra /tmp/cron.zimbra   
su - zimbra -c "zmschedulebackup -D" 
Mailbox Server:
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK 
cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
cat /opt/zimbra/zimbramon/crontabs/crontab.store >> /tmp/cron.zimbra
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra  
crontab -u zimbra /tmp/cron.zimbra   
su - zimbra -c "zmschedulebackup -D" 
/etc/init.d/crond restart
MTA+Proxy Server:
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK  
cat /opt/zimbra/zimbramon/crontabs/crontab > /tmp/cron.zimbra
cat /opt/zimbra/zimbramon/crontabs/crontab.mta >> /tmp/cron.zimbra
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra 
crontab -u zimbra /tmp/cron.zimbra   


On ZCS v8.7.x:

LDAP Server:
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK 
cat /opt/zimbra/conf/crontabs/crontab > /tmp/cron.zimbra
cat /opt/zimbra/conf/crontabs/crontab.ldap >> /tmp/cron.zimbra  
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra  
crontab -u zimbra /tmp/cron.zimbra   
su - zimbra -c "zmschedulebackup -D" 
Mailbox Server:
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK 
cat /opt/zimbra/conf/crontabs/crontab > /tmp/cron.zimbra
cat /opt/zimbra/conf/crontabs/crontab.store >> /tmp/cron.zimbra
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra  
crontab -u zimbra /tmp/cron.zimbra   
su - zimbra -c "zmschedulebackup -D" 
MTA+Proxy Server:
cp -pvr /var/spool/cron/zimbra  /tmp/zimbra.cron.BAK  
cat /opt/zimbra/conf/crontabs/crontab > /tmp/cron.zimbra
cat /opt/zimbra/conf/crontabs/crontab.mta >> /tmp/cron.zimbra
echo "# ZIMBRAEND -- DO NOT EDIT ANYTHING BETWEEN THIS LINE AND ZIMBRASTART" >> /tmp/cron.zimbra 
crontab -u zimbra /tmp/cron.zimbra   


Note : We have to restart Cron service after installing new crontab file.

Commands to restart Cron service on different OS versions.

Ubuntu 12.04/14.04/16.04

service cron restart

RHEL/CentOS 7.x

systemctl restart crond

RHEL/CentOS 6.x

service crond restart



Submitted by: Heera Singh Koranga

Jump to: navigation, search