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.

One of our servers has around 20-25 different cron jobs scheduled on it. Usually, we periodically check-in the cron jobs to a file in the repo using crontab -l > cron.jobs

While bringing up a new server, which is a replica of the previous server (in terms of OS and deployed code base), is it possible to source the cron jobs for the new server from a file containing valid cron jobs?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You should specify a user name with system crontab files placed in /etc/cron.d, e.g.

* * * * * USERNAME COMMAND

The command crontab -l dumps current user's crontab without user name. If you want to re-use it you can import it under any user on a new system

crontab -u USER1 -l | ssh USER2@NEW_SYSTEM "crontab -u USER2 -"

Or copy the dump cron.jobs to this system

crontab -u USER1 -l > cron.jobs
crontab -u USER2 cron.jobs
share|improve this answer

Just drop the file into /etc/cron.d.

share|improve this answer
    
Thanks! Your answer works, but doing crontab < cron.jobs was what I was looking for. –  mu 無 Aug 28 '13 at 6:27
1  
ansh0l, you should probably write that up as an answer and post it yourself; in a couple of days, the system will allow you to accept that one. If that's really the answer you were looking for, then doing this is entirely within the spirit of SF, and correctly marks your answer as the one that most satisfied you for those who read this question in the future. –  MadHatter Aug 28 '13 at 6:33
    
@MadHatter Thanks for the hat-tip. For now, I have marked another answer by dsumsky as the accepted answer. –  mu 無 Aug 28 '13 at 14:53

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.