I have two files where in I have listed my cronjobs:


Now I am using crontab in the following manner:

crontab cron.dev1.txt and

crontab cron.dev2.txt

When I do crontab -e, I see that only the jobs listed in crontab cron.dev2.txt are listed. It seems that first the jobs in crontab cron.dev1.txt are loaded and then replaced by crontab cron.dev2.txt.

Is there a way to load jobs using crontab listed in several different files.?


The crontab(1) man page notes you can populate the crontab via stdin:

  The  first  form  of this command is used to install a new crontab from
  some named file or standard  input  if  the  pseudo-filename  ``-''  is

So we can do this:

$ cat cron.dev1.txt
* * * * * /bin/script1
$ cat cron.dev2.txt
* * * * * /bin/script2
$ cat cron.dev*.txt | crontab -
$ crontab -l
* * * * * /bin/script1
* * * * * /bin/script2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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