[et-mgmt-tools] Cobbler reposync cron script
Adrian Revill
adrian.revill at shazamteam.com
Fri Jun 13 13:01:23 UTC 2008
Yes feel free to add it.
I tried the change to use "cobbler list repo" and it works fine.
Michael DeHaan wrote:
>
> Adrian Revill wrote:
>> Just in case anyone needs a script to run cobbler reposync from cron,
>> here is one i have written. It runs each repo in turn, and gives each
>> a number of tries (10) to over come problems with failing syncs.
>>
>> #!/bin/bash
>>
>> TRIES=10 # number of times to try and run reposync
>> LOGFILE="/var/log/cobbler/cobbler_reposync.log"
>>
>> function running {
>> PID=$(ps ax| awk '/cobbler reposync/ && !/awk/ {print ($1)}')
>> if [ -z $PID ]
>> then
>> log "cobbler reposync is not running"
>> return 1
>> fi
>> log "cobbler reposync is running PID=$PID"
>> return 0
>> }
>>
>> function log {
>> logger -t "COBBLER_REPOSYNC" -- $1
>> }
>>
>> function run {
>> try=1
>> ret=1
>> while [ $try -le $TRIES ]
>> do
>> running
>> ok=$?
>> if [ $ok -eq 0 ]
>> then
>> log "Already running, aborting"
>> break
>> fi
>> log "Attempt $try for $1"
>> cobbler reposync --only=$1 2>&1 >> $LOGFILE
>> ret=$?
>> if [ $ret -eq 0 ]
>> then
>> break
>> fi
>> log "Attempt $try failed"
>> try=$[ $try + 1 ]
>> done
>> if [ $ret -eq 0 ]
>> then
>> log "Compleated $1"
>> else
>> log "Too many trys or already running, giving up on $1"
>>
>> fi
>> }
>>
>> log "Starting"
>> mv $LOGFILE $LOGFILE.1
>>
>> for name in $(awk '/name:/ {print($2)}' /var/lib/cobbler/repos)
>> do
>> run $name
>> done
>>
>> _______________________________________________
>> et-mgmt-tools mailing list
>> et-mgmt-tools at redhat.com
>> https://www.redhat.com/mailman/listinfo/et-mgmt-tools
>
> Nice! Do you mind if I put this in a 'contrib' directory in cobbler's
> version control so other people can find it later?
>
> We can mention this on the Wiki too.
>
> One small change I'd make is to make the last awk line run 'cobbler repo
> list' instead of grepping the file, that way
> it works regardless of the storage backend -- though everyone pretty
> much uses the stock one.
>
> --Michael
>
> _______________________________________________
> et-mgmt-tools mailing list
> et-mgmt-tools at redhat.com
> https://www.redhat.com/mailman/listinfo/et-mgmt-tools
>
>
--
View this message in context: http://www.nabble.com/Cobbler-reposync-cron-script-tp17801508p17822886.html
Sent from the et-mgmt-tools mailing list archive at Nabble.com.
More information about the et-mgmt-tools
mailing list