我有两个文件在我列出我的cronjobs:
cron.dev1.txt cron.dev2.txt
现在我用下面的方式使用crontab :
crontab cron.dev1.txt和
crontab cron.dev2.txt
当我做crontab -e ,我看到只列出了crontab cron.dev2.txt中列出的作业。 看来,首先在crontab cron.dev1.txt中的作业加载,然后由crontab cron.dev2.txt取代。
有没有办法使用列在几个不同的文件中的crontab加载作业?
crontab(1)手册页提示您可以通过stdin填充crontab:
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 given.
所以我们可以做到这一点:
$ cat cron.dev1.txt * * * * * /bin/script1 $ cat cron.dev2.txt * * * * * /bin/script2 $ cat cron.dev*.txt | crontab - $ crontab -l * * * * * /bin/script1 * * * * * /bin/script2 $