1824638 Members
4632 Online
109672 Solutions
New Discussion юеВ

cron transfer

 
SOLVED
Go to solution
khilari
Regular Advisor

cron transfer

Hi people, okay this is the situation. I have to transfer all thecron jobs from one system to another.Now, do i copy crontab -l into a file and then transfer it to the other system and then paste it on crontab -e.
Furthermore,do i have to put enteries in the following directories under /var/spool/cron
(h8193n2)root# cd /var/spool/cron
(h8193n2)root# ll
total 12
dr-xr-xr-x 2 bin bin 96 May 21 07:53 atjobs
-r--r--r-- 1 bin bin 342 Jun 10 1996 crontab.root
dr-xr-xr-x 2 bin bin 1024 May 21 07:56 crontabs
drwxrwxrwt 2 root root 4096 May 25 11:10 tmp

If i go into individual directories examples lets say crontabs i get

(h8193n2)root# cd crontabs
(h8193n2)root# ll
total 14
-r--r--r-- 1 root adm 811 Sep 15 1999 adm
-r--r--r-- 1 root hbo 459 Sep 15 1999 hbo
-r-------- 1 root sys 2806 May 21 07:56 root
-r--r--r-- 1 root users 0 Oct 5 1999 slove
-r-------- 1 root hbo 1300 May 19 09:33 sqldba

so do i put in enteries here also, or crontab -l are the only enteries i should be concerned about.......

5 REPLIES 5
Pete Randall
Outstanding Contributor

Re: cron transfer

You can just transfer the /var/spool/cron/crontabs directory to the new server or you re-create via "crontab -l" and "crontab -e". Make sure you also match up the cron.allow and cron.deny files in /usr/lib/cron so the permissions are the same between the two machines.


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: cron transfer

Hi:

The 'crontab' files are found in the directory:

/var/spool/cron/crontabs

Users are allowed or denied access as governed by:

/var/adm/cron/at.allow
/var/adm/cron/at.deny
/var/adm/cron/cron.allow
/var/adm/cron/cron.deny

You could copy from server-to-server the contens of the '/var/spool/cron/crontabs' directory and copy (or merge) the contents of the 'at.*' and 'cron.*' files.

Regards!

...JRF...
Ivan Ferreira
Honored Contributor
Solution

Re: cron transfer

You have two options:

Option 1

Save your crontab to a file:

Use crontab -l > username.cron

Restore your crontab file on the other system:

crontab username.cron

You don't have to use crontab -e and paste, just specify the file name and the contents of the file will be used as your crontab. The /var/spool/cron/crontabs/username file will be created.


Option 2:

"tar" the crontabs directory and restore in the other system.

cd /var/spool/cron/crontabs
tar cvf cron.tar *

On the other system

cd /var/spool/cron/crontabs
tar xvf cron.tar

This will transfer all cron jobs from one system to another.


Just be carefull, in both methods, you will be replacing your current cron jobs. If you don't want to do that, you have to do it one by one, using crontab -e and pasting the entries that you need.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
James R. Ferguson
Acclaimed Contributor

Re: cron transfer

Hi (again):

Oops. One more thing. Having transferred and/or merged the necessary files, restart 'cron':

# /sbin/init.d/cron stop
# /sbin/init.d/cron start

Regards!

...JRF...
Ivan Ferreira
Honored Contributor

Re: cron transfer

Cron read the cron files every minute, so I think that is not neccesary to restart cron.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?