How to delegate inside crontab to use another file as crontab? aka crontab in svn / cvs?

Perhaps this is a different solution. I created a web application that requires 5-10 clones to support it and various intervals. I want to register crontab in version control so that it can be easily deployed to other servers.

I would like to be able to put a line in the / etc / crontab file to say that it looks in the /myapp/app.crontab file and treats all the lines in this file as crontab entries ... i.e.

0 1 * * *    root   /bin/sh /do/something.sh

Why not just check / etc / crontab? Since when deploying from server to server, some servers may have different entries in their crontabs, which I do not want to interfere with.

Any ideas? What do other people do to store a bunch of crontab entries in rev ctrl?
Thanks.

+3
source share
4 answers

Place your crontab file in /etc/cron.d/- either in the verification file or a symbolic link to the extracted file.

+4
source

We use a completely different approach to this problem in the project I'm working on.

Perl script, crontab.pl, crontab. , crontab , crontab.pl script .

script . :

*/5 * * * * /usr/local/apache/crontab.pl 5    > /var/log/crontab.log 2>&1 # 5 minute interval
1   * * * * /usr/local/apache/crontab.pl 60   > /var/log/crontab.log 2>&1 # 1 hour interval
1   1 * * * /usr/local/apache/crontab.pl 3600 > /var/log/crontab.log 2>&1 # 1 day interval

, .

+1

( ) crontab, script, :

0 * * * */path/to/app/hourly.sh 0 0 * * */path/to/app/daily.sh 0 1 * * 5/path/to/app/weekly.sh

hourly.sh , , daily.sh , , ..

, cron , crontab, , , 14 , 12 , 2,1 , script , Heisenbug.

- .

0

, , - crontab , script crontab , .

:

crontab filename

Or for a specific user (for this he must have access to the superuser):

crontab -u my_web_user filename

One big caveat is that it assumes that there is only one crontab entry for each user and that it is saved in SCM. If someone else edits crontab on the server, these changes will be lost during the next deployment. Therefore, keep this in mind.

0
source

Source: https://habr.com/ru/post/1702745/


All Articles