Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have recently done a migration from on dedicated centos server to another dedicated centos server. There were few backup cron jobs was runing on my old server. I would like to copy them to new server. Could anyone guide me please. using bash is prefereable.

share|improve this question

2 Answers 2

Centos uses cronie, and it reads files/crontabs from the following places:

/etc/cron.d/ # Put any readable file here. Syntax example in /etc/crontab
/etc/cron.daily/ # Any root executable files here. runs daily
/etc/cron.deny # newline separated list of users to deny crontab. 
/etc/cron.hourly/ # Same setup as daily
/etc/cron.monthly/ # same setup as daily
/etc/crontab # Shell variables that all cron jobs source before running.
/etc/cron.weekly/ # same setup as daily 

/var/spool/cron/* # most user defined cron jobs are put here. 
share|improve this answer

You will have to recreate the cron jobs more or less manually.

  • Copy the relevant crontab entries to the crontab on the new server. I usually just use copy&paste for this with the help of the clipboard of my work machine and two ssh sessions.
  • in case of files in /etc/cron.d or /etc/cron.daily etc., copy the scripts from there to the new server
  • Make sure any scripts, files or other resources you refer to in your current cron jobs are available on the new server. What these resources are is entirely dependent on your local config.
share|improve this answer
    
if you're giong to copy the files like this, then make sure you restart crond after. –  symcbean Jun 12 '12 at 8:47
    
What? Copypaste? Just copy the user-specific crontabs from /var/spool/cron and all the /etc/cron* stuff, and you are all set. –  Janne Pikkarainen Jun 12 '12 at 11:45
    
@JannePikkarainen: Yes, that works as well. Anyway, I like my method and I am usually faster this way. –  Sven Jun 12 '12 at 12:04
    
@SwenW: Faster than scp/rsync? Impressive :) –  Janne Pikkarainen Jun 12 '12 at 16:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.