复制cron作业从一台服务器到另一台服务器 – 使用bash prefereable

我最近做了一个从专用的centos服务器到另一个专用的centos服务器的迁移。 我的旧服务器上运行的备份cron作业很less。 我想将它们复制到新的服务器。 任何人都可以指导我。 使用bash是可取的。

Centos使用cronie,并从以下位置读取文件/ crontabs:

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

您将不得不手动重新创buildcron作业。

  • 将相关的crontab条目复制到新服务器上的crontab。 我通常只是使用我的工作机器的剪贴板和两个ssh会话的复制和粘贴。
  • /etc/cron.d/etc/cron.daily等文件中,将脚本从那里复制到新服务器
  • 确保新服务器上提供了当前cron作业中引用的任何脚本,文件或其他资源。 这些资源是完全取决于您的本地configuration。